---
title: LE-MQTT TO InfluxDBv2
slug: solutions/le-mqtt-to-influxdbv2
docTags: 
createdAt: 2023-05-08T11:10:42.000Z
---

# Overview

![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/2HOAEvcZkiWoZ65bpJ40p_functiondiagramsolutions-mqtttoinfluxv2drawio.png)

# How to use the solution using Docker

Here is an example to run **LE-MQTT-TO-InfluxDBv2&#x20;**&#x77;ith **Docker&#x20;**:

:::BlockQuote
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
:::

:::BlockQuote
**LE-MQTT-TO-InfluxDBv2&#x20;**&#x64;ocker image is available at [https://us-docker.pkg.dev/litmus-customer-facing/litmus-solutions-dev/le-mqtt-to-influxdbv2\:latest](https://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)

- **LE-MQTT-TO-InfluxDBv2**
- &#x20;also sends metrics about itself to InfluxDB such as the number of metrics gathered, added, written and dropped as well as the time spent in collecting and writing the metrics.
- The following InfluxDB template contains a dashboard to visualize these metrics for each instance of **LE-MQTT-TO-InfluxDBv2** :
  - [https://gist.github.com/amine-amaach/0035b2959d77943578dd424783122df0/raw/59fb6f4fc4f7eacba82d504cbf11d99d70a0d1aa/le-Ingestors-monitoring.yml](https://gist.github.com/amine-amaach/0035b2959d77943578dd424783122df0/raw/59fb6f4fc4f7eacba82d504cbf11d99d70a0d1aa/le-Ingestors-monitoring.yml)
- To install the template, go to Settings, choose Templates and enter the above URL, then click the LOOKUP TEMPLALTE button :&#x20;
- Under Dashboards select LE Ingestors | Performance Monitoring dashboard :

