Solutions

LE-MQTT TO InfluxDBv2

5min

Overview

Document image


How to use the solution using Docker

Here is an example to run LE-MQTT-TO-InfluxDBv2 with Docker :

docker run -itd --name le-mqtt-to-influxdbv2 -e INFLUX_HOST=http://influxdb-oss:8086 -e INFLUX_ORG=Litmus -e INFLUX_TOKEN=superSecureToken -e INFLUX_BUCKET=le-mqtt-to-influxdbv2 -e MQTT_HOST=tcp://mqtt:1883 -e MQTT_TOPICS=le-mqtt-to-influxdbv2/ -e MQTT_QoS=1 -e MQTT_PERSISTENT_SESSION=false -e MQTT_TIMEOUT=30s -e MQTT_CLIENT_ID=le-mqtt-to-influxdbv2-oss-test-client -e MQTT_USERNAME=username -e MQTT_PASSWORD=password -e TELEGRAF_MAX_UNDELIVERED_MESSAGES=5000 -e TELEGRAF_METRIC_BUFFER_LIMIT=10000 -e TELEGRAF_BATCH_SIZE=5000 -e TELEGRAF_MQTT_FLUSH_INTERVAL=5s -e TELEGRAF_HC_FLUSH_INTERVAL=3s -e TELEGRAF_HC_COLLECT_INTERVAL=3s -e TELEGRAF_DEBUG=true -e LE_NAME=LE-08:00:27:3b:0b:50 us-docker.pkg.dev/litmus-customer-facing/litmus-solutions-dev/le-mqtt-to-influxdbv2:latest

 Requirements

  • MQTT Broker v3.1.1
  • InfluxDB v2.x
  • If the subscribed data is not published by Litmus Edge instances, it must be a valid JSON string (or object) and have the same JSON schema used by Litmus Edge.

 Configuration Options

⚠️ When using Docker, the following environment variables must be set before running the container.

Environment variables

Description

Sample value

type

MQTT_HOST

Broker URL for the MQTT server or cluster

tcp://localhost:1883

String

MQTT_TOPICS

Topics that will be subscribed to

le-mqtt-to-influxdbv2/#

String

MQTT_QoS

QoS policy for messages.

1

Integer

MQTT_CLIENT_ID

The ID to assign to the client  when connecting to the broker.

LE-UniqueClientID

String

MQTT_USERNAME

The username to connect to the MQTT server.

admin

String

MQTT_PASSWORD

The password to connect to the MQTT server.

admin

String

MQTT_PERSISTENT_SESSION

Persistent session disables clearing of the client session on connection. In order for this option to work you must also set MQTT_CLIENT_ID to identify the client. To receive messages that arrived while the client is offline, also set the QoS option to 1 or 2 and don't forget to also set the QoS when publishing.

true

Boolean

MQTT_TIMEOUT

Connection timeout for initial connection in seconds.

30s

String

TELEGRAF_METRIC_BUFFER_LIMIT

Maximum number of unwritten metrics. Increasing this value allows for longer periods of InfluxDB downtime without dropping metrics at the cost of higher maximum memory usage.

10000

Integer

TELEGRAF_BATCH_SIZE

LE-MQTT-TO-InfluxDBv2 will send metrics to InfluxDB in batches of at most TELEGRAF_BATCH_SIZE metrics. This controls the size of writes that LE-MQTT-TO-InfluxDBv2 sends to InfluxDB.

5000

Integer

TELEGRAF_MAX_UNDELIVERED_MESSAGES

Maximum messages to read from the broker that have not been written to InfluxDB. For best throughput set based on the batch size TELEGRAF_BATCH_SIZE.

5000

Integer

TELEGRAF_MQTT_FLUSH_INTERVAL

Period is seconds between writes to InfluxDB from MQTT topics.

5s

String

TELEGRAF_HC_FLUSH_INTERVAL

Period is seconds between writes to InfluxDB from internal input (LE-MQTT-TO-InfluxDBv2 statistics).

3s

String

TELEGRAF_HC_COLLECT_INTERVAL

Period is seconds between each collect of LE-MQTT-TO-InfluxDBv2 statistics.

3s

String

TELEGRAF_DEBUG

Log at debug level.

true

Boolean

LE_NAME

Litmus Edge friendly name (used to name/identify the measurement).

LE-Local-VM

String

INFLUX_HOST

The InfluxDB URL.



String

INFLUX_ORG

Organization is the name of the organization you wish to write to.

Litmus

String

INFLUX_TOKEN

Token for authentication.

superSecureToken

String

INFLUX_BUCKET

Destination bucket to write into.

le-mqtt-to-influxdbv2

String

 How to use monitor LE-MQTT-TO-InfluxDBv2 performance (Optional)