# MQTT json file to influxdb

**URL:** <https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634>\
**Category:** General\
**Created:** [1 April 2022 07:55 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634 "2022-04-01T07:55:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxJ](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MaxJ](https://discourse.nodered.org/u/MaxJ)\
**Post date:** [1 April 2022 07:55 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/1 "2022-04-01T07:55:39Z")

</div>

Hello!

Im trying to send a JSON with data over MQTT which i convert to a javascript object and then send to influxDB which will later go to my grafana. However when i insert my data in influx the values come in as strings, i assume this is causing the problem with me not being able to display the values. Does anyone know how to fix this?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [1 April 2022 08:07 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/2 "2022-04-01T08:07:41Z")

</div>

Welcome to the forum!

Can you post your flow?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2022 09:00 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/4 "2022-04-01T09:00:39Z")

</div>

Feed the message you are feeding into influx into a debug node and show us what it looks like.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [1 April 2022 09:18 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/6 "2022-04-01T09:18:10Z")

</div>

Is this directly from a MQTT node?  
If so try setting the MQTT node to output a parsed JSON object.

![Screenshot-10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/576789d05e645edade55d4bb70fbbfd686d6bc47.png)

---

<div class="post-metadata">

**Author:** ![MaxJ](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MaxJ](https://discourse.nodered.org/u/MaxJ)\
**Post date:** [1 April 2022 09:20 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/7 "2022-04-01T09:20:25Z")

</div>

Yes, i'm outputting using that option in my MQTT node.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [1 April 2022 09:41 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/8 "2022-04-01T09:41:55Z")

</div>

What error message does InfluxDB give?

---

<div class="post-metadata">

**Author:** ![MaxJ](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MaxJ](https://discourse.nodered.org/u/MaxJ)\
**Post date:** [1 April 2022 09:48 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/9 "2022-04-01T09:48:34Z")

</div>

Theres no error, the values get inserted as strings, is there a way to convert them in node-red?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [1 April 2022 09:58 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/10 "2022-04-01T09:58:54Z")

</div>

What is creating the data in the first place? Looks like that is creating the strings and that would be the best place to fix it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2022 11:20 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/11 "2022-04-01T11:20:53Z")

</div>

First you have to decide what you want to write to the influx. The message you have shown has a nested object `bandwidth`. You can't write objects to influx, only fields and tags. Look at the help text for the influx node and it will tell you what the data has to look like. First you need to design the db schema though.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 April 2022 11:21 UTC](https://discourse.nodered.org/t/mqtt-json-file-to-influxdb/60634/12 "2022-04-15T11:21:07Z")

</div>

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