Elasticsearch Connector


Introduction

TRAX LRS provides an Elasticsearch connector which can be used to push the LRS data to an Elasticsearch database. This feature is accessible only from the console.

This connector pushes new data and updates existing data, based on TRAX LRS data models.

{warning} Breaking changes were introduced with Beta 4. The Elasticsearch connector is not compatible with Beta 3. Now, it pushes the entire statement records from the TRAX LRS database (see data models). Before Beta 4, it was pushing only the xAPI JSON data. There are also some changes in the configuration options.

Configuration

The default settings of the Elasticsearch connector can be changed in the .env file.

Host

The Elasticsearch server(s). Default is ["localhost:9200"].

ELASTIC_SEARCH_HOSTS=["localhost:9200"]

Username & Password

The credentials to access the Elasticsearch server(s).

ELASTIC_SEARCH_USERNAME=
ELASTIC_SEARCH_PASSWORD=

Batch Size

The number of records pushed in the same request. Default is 100. Higher values may result in memory issues.

ELASTIC_SEARCH_BATCH_SIZE=100

Indexes

The Elasticsearch indexes where the xAPI data must be stored. Default values are statements, agents, activities, agent_profiles and activity_profiles.

ELASTIC_SEARCH_STATEMENTS_INDEX=statements
ELASTIC_SEARCH_AGENTS_INDEX=agents
ELASTIC_SEARCH_ACTIVITIES_INDEX=activities
ELASTIC_SEARCH_AGENT_PROFILES_INDEX=agent_profiles
ELASTIC_SEARCH_ACTIVITY_PROFILES_INDEX=activity_profiles

Commands

Before using these commands, you must create a store in your LRS.

Pushing data

You can create pushing jobs separately for each store.

php artisan statements:elastic-push
php artisan agents:elastic-push
php artisan activities:elastic-push
php artisan agent-profiles:elastic-push
php artisan activity-profiles:elastic-push

The following parameters are optional. When not provided in the command line, some of them will be asked.

Option Example of value Description
--hosts ['localhost:9200'] The Elasticsearch server(s)
--username elastic-username The Elasticsearch username
--password 123456 The Elasticsearch password
--index statements The Elasticsearch index
--batch 50 The batch size
--owner 1 Internal ID of the LRS store
--noprompt Don't ask options (take defaults)
--restart Restart from the 1st record

Showing the push status

You can display the status of the last push with:

php artisan statements:elastic-push-status
php artisan agents:elastic-push-status
php artisan activities:elastic-push-status
php artisan agent-profiles:elastic-push-status
php artisan activity-profiles:elastic-push-status

When not provided in the command line, the following option will be asked.

Option Example of value Description
--owner 1 Internal ID of the LRS store

Resuming

When a push request fails or when the process is interrupted, you can resume it where it stopped. Relaunch the command and it will ask you if you want to resume or restart.

When the --noprompt option is used, it always tries to resume, except when the --restart option is used together.