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.
The default settings of the Elasticsearch connector can be changed in the .env
file.
If you are using Elastic Cloud, you can set the following default options:
ELASTIC_SEARCH_CLOUD_ID="your cloud id here"
ELASTIC_SEARCH_CLOUD_API_ID="your cloud API ID here"
ELASTIC_SEARCH_CLOUD_API_KEY="your cloud API key here"
If you are using a self-hosted Elasticsearch server, you can set the following default options:
ELASTIC_SEARCH_HOSTS=["localhost:9200"]
ELASTIC_SEARCH_USERNAME=
ELASTIC_SEARCH_PASSWORD=
The number of records pushed in the same request. Default is 100
. Higher values may result in memory issues.
ELASTIC_SEARCH_BATCH_SIZE=100
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
Before using these commands, you must create a store in your LRS.
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
By default, these commands assume that you are using a self-hosted Elasticsearch server.
If you want to use Elastic Cloud, you can add the --cloud
option in order to be prompted to entrer the Elastic Cloud settings.
You can also add the --cloudid
option to specify the Elastic Cloud ID.
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 |
--cloudid | xyz |
The Elastic Cloud ID |
--apiid | xyz |
The Elastic Cloud API ID |
--apikey | xyz |
The Elastic Cloud API key |
--batch | 50 |
The batch size |
--owner | 1 |
Internal ID of the LRS store |
--cloud | Ask the Elastic Cloud settings | |
--noprompt | Don't ask options (take defaults) | |
--restart | Restart from the 1st record |
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 |
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.