InfluxDB
InfluxDB is an open-source time-series database. It can be deployed at the edge and complements the storage provided by the Edge Xpert Core Data service. Data is exported to InfluxDB using the Application Service. You can find more information about the Application Service in the Application Service Overview.
Edge Xpert supports InfluxDB v2. For more information about InfluxDB see the Influx documentation.
InfluxDB Example
This example gives an overview of how to export data from the Virtual Device Service into InfluxDB using the Application Service. The export is set up using the Edge Xpert manager. The readings can be viewed using the InfluxDB command line. See the Application Service with InfluxDB Example for more details.
The following steps are required to run this example:
- Start the Edge Xpert services
- Export data to InfluxDB Using the Xpert Manager
- Check the readings
Starting the Edge Xpert Services
Note
The initial InfluxDB configurations (e.g. organization, bucket, token) are defined in the compose files in the /etc/edgexpert. To use your custom InfluxDB, copy the docker-compose file (docker-compose-security.yml in this example) to your working directory and modify the configurations.
For this example we will use InfluxDB, the Virtual Device Service and the Xpert Manager. The following command is used to start the services:
edgexpert up --secret sys-mgmt device-virtual influxdb xpert-manager
Note
The "--secret" and "sys-mgmt" options are required for the Edge Xpert Manager to create the application services
Export the data to Influx DB using the Xpert Manager
For this example we will use the Edge Xpert Manager to create the export to InfluxDB.
Bring up the Xpert Manager in a web browser by going to http://localhost:9090
Click the "Add Application Service" icon in the top right corner to bring up the Application Service onboarding wizard.
Fill in the following values, these are the default configuration values:
Description | Value |
---|---|
Name | Influx |
Destination | InfluxDB |
InfluxDBServerURL | http://influxdb:8086 |
InfluxDBOrganization | my-org |
InfluxDBBucket | my-bucket |
InfluxDBValueType | float |
Authentication Mode | Token |
Token | custom-token |
Leave the other values as default and click Save.
Check the Readings
You can check that the readings are being correctly gathered by using the InfluxDB CLI, as described below.
Check Readings Using the InfluxDB CLI
Events being written to InfluxDB can be monitored and queried in various ways.
You can use the following command to access the Influx command-line interface in the InfluxDB Docker container to query the readings measurement from the database.
docker exec -it influxdb influx query \
'from(bucket:"my-bucket")
|> range(start:-1h)
|> drop(columns: ["_start", "_stop"])
|> filter(fn: (r) => r._measurement == "readings")'
The command makes use of the Flux Scripting Language
- The from() function retrieves data from an InfluxDB data source.
- The range() function filters records based on time bounds.
- The drop() function removes specified columns from a table.
- The filter() function filters data based on conditions defined in a predicate function.