# How to send MQTT inputs to different outputs by topic

**URL:** <https://community.influxdata.com/t/how-to-send-mqtt-inputs-to-different-outputs-by-topic/14841>\
**Category:** Store\
**Tags:** influxdb, telegraf, iot, sensors\
**Created:** [June 16, 2020, 12:15pm UTC](https://community.influxdata.com/t/how-to-send-mqtt-inputs-to-different-outputs-by-topic/14841 "2020-06-16T12:15:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihnea17](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mihnea17](https://community.influxdata.com/u/mihnea17)\
**Post date:** [June 16, 2020, 12:15pm UTC](https://community.influxdata.com/t/how-to-send-mqtt-inputs-to-different-outputs-by-topic/14841/1 "2020-06-16T12:15:22Z")

</div>

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”  
]

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [June 17, 2020, 12:31am UTC](https://community.influxdata.com/t/how-to-send-mqtt-inputs-to-different-outputs-by-topic/14841/2 "2020-06-17T00:31:57Z")

</div>

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`](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#input-plugins) option. In the output you can configure the HTTP output to send only data with the tag using [`tagpass`](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#metric-filtering).

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

```auto
[[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"]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2feb065bdfd5e4b7728243aa3b9192ad3e8447c1.png) [@system](https://community.influxdata.com/u/system)\
**Post date:** [June 17, 2020, 1:11pm UTC](https://community.influxdata.com/t/how-to-send-mqtt-inputs-to-different-outputs-by-topic/14841/3 "2020-06-17T13:11:15Z")

</div>

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