Skip to content

InfluxDB

InfluxDB Overview

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.x, see the Influx documentation. for more information.

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:

  1. Start the Edge Xpert services
  2. Export data to InfluxDB Using the Xpert Manager
  3. 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.

For the following example, we use InfluxDB, the Virtual Device Service and the Xpert Manager.

  1. To use your custom InfluxDB, you can create a local docker-compose-security.yml and modify the configurations to match your InfluxDB, see Docker Compose Override for more information.
    version: '3.7'
    
    services:
      influxdb:
        environment:
          DOCKER_INFLUXDB_INIT_MODE: <your influxdb mode>
          DOCKER_INFLUXDB_INIT_USERNAME: <your influxdb username>
          DOCKER_INFLUXDB_INIT_PASSWORD: <your influxdb password>
          DOCKER_INFLUXDB_INIT_ORG: <your influxdb org>
          DOCKER_INFLUXDB_INIT_BUCKET: <your influxdb bucket>
          DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: <your influxdb admin token>
    
  2. Run the following command 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 the next step, we use the Edge Xpert Manager to create an application service that will export the data to InfluxDB.

  1. Bring up the Xpert Manager in a web browser by going to http://localhost:9090
    Application Service Window
  2. Click the Add Add App Service icon in the top right corner to bring up the Application Service onboarding wizard.
  3. 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

  4. Leave the other values as default and click Save.

Check Readings Using the InfluxDB CLI

You can check that the readings are being correctly gathered by using the InfluxDB CLI, as described below.

Use the following command to access the Influx command-line interface in the InfluxDB Docker container and 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.