# Beginner question: MQTT \> Transform \> Influx with TICK stack?

**URL:** <https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757>\
**Category:** Telegraf\
**Created:** [July 3, 2018, 10:15am UTC](https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757 "2018-07-03T10:15:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@Christoph](https://community.influxdata.com/u/Christoph)\
**Post date:** [July 3, 2018, 10:15am UTC](https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757/1 "2018-07-03T10:15:32Z")

</div>

Hi there,

Quick question - I have an existing system that collects sensor data, it looks like this:  
**Sensor \> MQTT \> Processor \> Postgres**  
I now want to hook in the TICK stack by connecting it to the MQTT as a subscriber in parallel.

The problem is that the sensor data is basically a json map with various sensor values.  
Those are persisted in Postgres as JSONB fields.  
This means that a single entry contains multiple sensor readings, e.g. {temp: 50.0, humidity: 30,…} etc  
The content varies per sensor.

This probably means - if I’m correct - that I need to transform/dissect the message content before persisting to Influx - **how would I do that?**

Thanks a lot,  
Christoph

---

<div class="post-metadata">

**Author:** ![davidgs](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/davidgs/32/6936_2.png) [@davidgs](https://community.influxdata.com/u/davidgs)\
**Post date:** [July 3, 2018, 5:04pm UTC](https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757/2 "2018-07-03T17:04:01Z")

</div>

Hi @Christoph,

It’s actually a lot easier than you think. I was, like you, over-thinking the whole thing the first time I tried to set up an Influx/MQTT connection. The way to do it is Sensor–\>MQTT–\>Telegraf–\>InfluxDB.

I wrote a blog post about doing this with TheThingsNetwork a month or so ago which might be helpful:[Enabling The Things Network for InfluxDB | InfluxData](https://www.influxdata.com/blog/enabling-the-things-network-for-influxdb/) But essentially, all you need to do is configure the Telegraf HQTT plugin:

```
[[inputs.mqtt_consumer]]
servers = ["tcp://your.mqttserver.com:1883"]
qos = 0
connection_timeout = "30s"
topics = ["+/devices/+/up"]
client_id = ""
username = “username"
password = “password"
data_format = "json"

```

And let Telegraf do the rest. It will automatically pull out and numeric or boolean values and insert them into InfluxDB for you.

Hope that helps!  
dg

---

<div class="post-metadata">

**Author:** ![Christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@Christoph](https://community.influxdata.com/u/Christoph)\
**Post date:** [July 4, 2018, 1:13pm UTC](https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757/3 "2018-07-04T13:13:43Z")

</div>

Thanks a lot @davidgs, I’ll try that.

Just out of curiosity, is there a possibility to use is it as a transformation component between two MQTT queues as well? Or parts of the TICK stack?

---

<div class="post-metadata">

**Author:** ![davidgs](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/davidgs/32/6936_2.png) [@davidgs](https://community.influxdata.com/u/davidgs)\
**Post date:** [July 12, 2018, 4:33pm UTC](https://community.influxdata.com/t/beginner-question-mqtt-transform-influx-with-tick-stack/5757/4 "2018-07-12T16:33:01Z")

</div>

I guess it’s possible. I also use Kapacitor with the MQTT output configured so I can write data from Kapacitor to an MQTT broker, so I guess it would be possible to read from a broker, use Kapacitor to transform the data, and then write it back to an MQTT broker as well.

Interesting idea.

dg
