Skip to content

InfluxDB Data Adapter — Walkthrough#

This tutorial stores and serves data directly from InfluxDB, using the microservices architecture introduced in Tutorial 02.

At the end, you'll have ATLAS connected to a popular off-the-shelf timeseries database.

In this tutorial you:

Tip

These code samples are in C# for .NET 5.0, and use McLaren NuGet packages to keep things as simple as possible.

We recommend you follow this tutorial even if you are planning to do your integration in another language.
The concepts should translate very easily once you have a working example.

Prerequisites#

You'll want to complete the Quick-Start and Microservices tutorials first.

This should get you setup with everything you need.

Step 1: Stop your existing Docker stack#

Hit Ctrl+C to stop your Docker Compose stack from the previous tutorial.

Step 2: Edit the Docker Compose deployment#

Info

If you already have InfluxDB running in your development environment, you could skip this step and use the existing deployment when you configure the RTA Influx Data Service.

Watch out for port clashes if you run them side-by-side. Remember that you can remap ports in Docker.

InfluxDB#

Modify the docker-compose.yaml to add InfluxDB as an extra service:

Create a directory for the InfluxDB volume.

For example:

mkdir C:\rta\influxdb

Add InfluxDB with the volume mount:

services:
    influxdb:
        image: influxdb:1.8
        restart: always
        ports:
        - "8086:8086"
        volumes:
        - C:\rta\influxdb:/var/lib/influxdb
        environment:
            INFLUXDB_DB: "rtademo"
            INFLUXDB_ADMIN_USER: "admin"
            INFLUXDB_ADMIN_PASSWORD: "admin"

    # ...

Create a directory for the InfluxDB volume.

For example:

mkdir -p /tmp/rta/influxdb

Add InfluxDB with the volume mount:

services:
    influxdb:
        image: influxdb:1.8
        restart: always
        ports:
        - "8086:8086"
        volumes:
        - /tmp/rta/influxdb:/var/lib/influxdb
        environment:
            INFLUXDB_DB: "rtademo"
            INFLUXDB_ADMIN_USER: "admin"
            INFLUXDB_ADMIN_PASSWORD: "admin"

    # ...

Schema Mapping Service and Influx Data Service#

Modify the docker-compose.yaml to add these two extra services:

Create a directory to hold files for the Schema Mapping Service (rta-schemamappingsvc).

For example:

mkdir C:\rta\schema-mappings

Add the Schema Mapping Service (rta-schemamappingsvc) and Influx Data Service (rta-influxdatasvc) — which will be the data adapter for InfluxDB:

services:
    influxdb:
        image: influxdb:1.8
        restart: always
        ports:
        - "8086:8086"
        volumes:
        - C:\rta\influxdb:/var/lib/influxdb
        environment:
            INFLUXDB_DB: "rtademo"
            INFLUXDB_ADMIN_USER: "admin"
            INFLUXDB_ADMIN_PASSWORD: "admin"

    rta-schemamappingsvc:
        image: mclarenapplied/rta-schemamappingsvc:latest
        restart: always
        ports:
        - "2680:2680"
        - "2682:2682"
        volumes:
        - C:\rta\schema-mappings:/data/rta-schema-mappings
        environment:
        - RTA_Store=File
        - RTA_FilePath=/data/rta-schema-mappings

    rta-influxdatasvc:
        image: mclarenapplied/rta-influxdatasvc:latest
        restart: always
        depends_on:
        - rta-schemamappingsvc
        - influxdb
        ports:
        - "2690:2690"
        environment:
        - RTA_DataSource=rta-influxdatasvc
        - RTA_SchemaMappingGrpcUri=http://rta-schemamappingsvc:2682/
        - RTA_InfluxUri=http://influxdb:8086/

    # ...

Create a directory to hold files for the Schema Mapping Service (rta-schemamappingsvc).

For example:

mkdir -p /tmp/rta/schema-mappings

Add the Schema Mapping Service (rta-schemamappingsvc) and Influx Data Service (rta-influxdatasvc) — which will be the data adapter for InfluxDB:

services:
    influxdb:
        image: influxdb:1.8
        restart: always
        ports:
        - "8086:8086"
        volumes:
        - /tmp/rta/influxdb:/var/lib/influxdb
        environment:
            INFLUXDB_DB: "rtademo"
            INFLUXDB_ADMIN_USER: "admin"
            INFLUXDB_ADMIN_PASSWORD: "admin"

    rta-schemamappingsvc:
        image: mclarenapplied/rta-schemamappingsvc:latest
        restart: always
        ports:
        - "2680:2680"
        - "2682:2682"
        volumes:
        - /tmp/rta/schema-mappings:/data/rta-schema-mappings
        environment:
        - RTA_Store=File
        - RTA_FilePath=/data/rta-schema-mappings

    rta-influxdatasvc:
        image: mclarenapplied/rta-influxdatasvc:latest
        restart: always
        depends_on:
        - rta-schemamappingsvc
        - influxdb
        ports:
        - "2690:2690"
        environment:
        - RTA_DataSource=rta-influxdatasvc
        - RTA_SchemaMappingGrpcUri=http://rta-schemamappingsvc:2682/
        - RTA_InfluxUri=http://influxdb:8086/

    # ...

Note

You should still have the other services:

  • rta-sessionsvc
  • rta-configsvc
  • rta-datasvc (optional for this tutorial)
  • rta-gatewaysvc

Update Gateway Service#

Modify the Gateway Service environment to include the URI for the Influx Data Service.

This sets the data adapter up as a data source, which we will name rta-influxdatasvc to keep the naming consistent:

rta-gatewaysvc:
    image: mclarenapplied/rta-gatewaysvc:latest
    restart: always
    depends_on:
    - rta-sessionsvc
    - rta-configsvc
    - rta-datasvc
    - rta-influxdatasvc
    ports:
    - "8080:80"
    environment:
    - RTA_SessionServiceUri=http://rta-sessionsvc:2650
    - RTA_ConfigServiceUri=http://rta-configsvc:2660
    - RTA_DataServiceUris__rta-datasvc=http://rta-datasvc:2670
    - RTA_DataServiceUris__rta-influxdatasvc=http://rta-influxdatasvc:2690

Note

The Gateway Service is configured to talk to the data adapter service (RTA Influx Data Service), not directly to InfluxDB.

Start the Stack#

Start the services from a terminal in the folder where you saved the docker-compose.yaml file:

docker compose up

Step 3: Check the Services#

HTTP#

Using a web browser, make sure all these health endpoints are reporting Healthy:

Service /health link
rta-gatewaysvc http://localhost:8080/health
rta-sessionsvc http://localhost:2650/health
rta-configsvc http://localhost:2660/health
rta-datasvc http://localhost:2670/health
rta-schemamappingsvc http://localhost:2680/health
rta-influxdatasvc http://localhost:2690/health

If a service says it is Unhealthy, the console log output should say why.

gRPC#

Using grpcui from a terminal:

grpcui -plaintext localhost:2682

This will check that the Schema Mapping Service gRPC API is available.

Step 4: Run the Demo#

Open the tutorial solution in your development environment (e.g. Visual Studio Code).

This time, you will be running RTA.Examples.Influx.

From the terminal, navigate to this sub-directory, and then:

dotnet run

If the service has been setup correctly, this will load some sample data into InfluxDB and create an example session.

You can create more sessions by running it again.

Step 5: Test the Session#

Browse the sessions in ATLAS and identify the InfluxDB session.

Info

If you followed the previous tutorials, you should have some other sessions.

The Data Service is still running, so these other sessions should still load and display data.

Load an InfluxDB session in ATLAS to make sure it's working.
You should be able to browse and add parameters to displays, and see the data download.

As before, in the docker compose terminal, you will see activity as requests to the Gateway Service (rta-gatewaysvc) are proxied through to the other services.

Next Steps#

Review the changes and the sample project to understand how the services are working together.