Telegraf provides integration of MQTT topics through the MQTT Consumer input plugin. Telegraf collects the metrics from the messages on the topic, processes them, and sends them to Lightstep Observability using the OpenTelemetry output plugin.

To complete the integration, you will:

  • Configure Telegraf to ingest metrics from an MQTT topic
  • Configure the OpenTelemetry output plugin

Configure the Telegraf MQTT input plugin

In the Telegraf configuration file, add configuration for the MQTT servers and topics. The data_format setting tells Telegraf how to translate the message bodies. There are additional settings available that are specific to the data format you use. You can find complete configuration details in the MQTT Consumer plugin documentation.

1
2
3
4
5
6
7
8
[[inputs.mqtt_consumer]]
  servers = [
    "tcp://broker:1883"
  ]
  topics = [
    "test/topic"
  ]
  data_format = "json"

Configure the OpenTelemetry output plugin

To deliver metrics to Lightstep Observability you configure the Telegraf OpenTelmetry output plugin. This plugin sends metrics to Lightstep using gRPC.

This example shows the plugin configured without TLS:

1
2
3
4
5
6
7
[[outputs.opentelemetry]]
  service_address = "ingest.lightstep.com:443"
  insecure_skip_verify = true

  # Additional gRPC request metadata
  [outputs.opentelemetry.headers]
    lightstep-access-token = "$LS_ACCESS_TOKEN"

For more details regarding configuring the OpenTelemetry output plugin see the official Telegraf documentation.

Validate metrics are reporting to Lightstep

You can validate that the metrics are reporting to Lightstep from the Metric details section of the Project Settings page.

  1. Open the Project settings page and scroll to the Metric details section.

  2. Search for MQTT metric names. Search for metric

  3. If needed, select the metric to edit the description and how the units are displayed in Lightstep.

View metrics in Lightstep

After you have Lightstep ingesting metrics from the MQTT Consumer endpoint, you can use the Lightstep Terraform Provider to create a dashboard for the metrics.

Additional resources