How to send MQTT inputs to different outputs by topic

Hello,

I have a system that receives different sensor data on different topics. I use Telegraf to store it in InfluxDB, but I also want some of that data to be sent using HTTP (only data received from “esp32/spots”). Is there a way of doing that?

This is my Telegraf input conf:

[[inputs.mqtt_consumer]]
servers = [“tcp://192.168.0.153:1883”]
topics = [
“sensors”,
“spots”,
“esp32/spots”,
“esp32/rssi”,
“esp8266/env”,
“esp8266/rssi”
]

You can use a tag to decide where to send the data. The topic can be added as a tag in the mqtt_consumer using the topic_tag option or you could add a static tag using the tags option. In the output you can configure the HTTP output to send only data with the tag using tagpass.

Here is the basic layout with only the routing options shown:

[[inputs.mqtt_consumer]]
  topic_tag = "topic"

[[outputs.influxdb]]
  # everything will go here, if you want to exclude the "esp32/spots" topic
  # you would use tagdrop here.

[[outputs.http]]
  [outputs.http.tagpass]
    topic = ["esp32/spots"]

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.