# Multiple object to Influxdb issue

**URL:** <https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132>\
**Category:** General\
**Created:** [10 July 2019 21:21 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132 "2019-07-10T21:21:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [10 July 2019 21:21 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/1 "2019-07-10T21:21:36Z")

</div>

Hi All,  
i want to transmit data to Grafana by Influxdb :

**This is the msg.payload :**  
[{"channel":89,"type":"counter","unit":"null","value":435,"name":"hoursCell89"},{"channel":16,"type":"voltage","unit":"v","value":5.5,"name":"voltCell16"},{"channel":17,"type":"current","unit":"a","value":0.2,"name":"ampCell17"},{"channel":25,"type":"temp","unit":"c","value":29.4,"name":"tempTDS25"}]

**This is the same in the Debug :**  
 ![object](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f08f18a0196eed5b3445ad0a0c11829b7519a2e2.jpeg)  
You can see in this example the [mqtt CAYENNE](https://mydevices.com/cayenne/features/) protocole:

- each object got : "channel" , "type", "unit", "value" , "name". Each channel corresponding to a sensor/data. The order of these channels is completely random.
- there is 4 objects in this array . It's depend on changing values : sometimes only 1 object, sometimes 6 objects.

This is the `SELECT* FROM stations` result in Influxdb :

 ![influx](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/43d937f1f628afd834b83e44ac0bbc8851b4319e.jpeg)  
The last line is the example above result : We can see `channel:89`, `channel_1:16`.... but not all 4 objects !

inevitably, in Grafana the `channel:25` named `tempTDS25`, does not work:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/42f5c4412dcfa81a002b7970885d8525843c8dcd.png)

The `channel:89` named `hoursCell89`is working because it is often on the first object :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/db029aecb48062bb3f8c15e8d3c7c3fe4b870077.png)

**Does anyone know how influxdb can handle multiple objects so that I can display each sensor / data in Grafana with its name and value?  
Ideally, do not touch the msg.payload ... 🙄**

---

<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:** [11 July 2019 08:07 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/2 "2019-07-11T08:07:31Z")

</div>

Is this a question about how to get data out of influx into grafana, in which case it is nothing to do with node-red, or a question about how to write the data you show to influx from node-red? If the latter then you have not told us how you are writing the data to influx.

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [11 July 2019 08:39 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/3 "2019-07-11T08:39:00Z")

</div>

Actually, I hesitated to post this topic here, because it is between Node-Red and influxDB.  
I wanted to know if anyone had ever met this case. Otherwise, of course I would post on the forum influxDB.

---

<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:** [11 July 2019 09:16 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/4 "2019-07-11T09:16:41Z")

</div>

You still haven't told us how you are writing the data to influx from node red.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 July 2019 09:22 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/5 "2019-07-11T09:22:17Z")

</div>

Are you using the correct format to post data to influx?  
Please have a look at the examples given in [node-red-contrib-influxdb](https://flows.nodered.org/node/node-red-contrib-influxdb) and compare with your format.

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [11 July 2019 09:54 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/6 "2019-07-11T09:54:14Z")

</div>

@Paul-Reed :

> [@Paul-Reed](#):
>
> node-red-contrib-influxdb

this example looks like my payload with multiple objects that have the same name :

```auto
[{"id":"eba91e98.1456e","type":"influxdb","z":"b061b303.4f9e5","hostname":"127.0.0.1","port":"8086","database":"aTimeSeries","name":"aTimeSeries"},{"id":"9555a67c.6aaa58","type":"function","z":"b061b303.4f9e5","name":"multiple readings","func":"msg.payload = [\n [{\n numValue: 10,\n randomValue: Math.random()*10,\n strValue: \"message1\",\n time: new Date(\"2015-12-28T19:41:13Z\").getTime()\n },\n {\n tag1:\"sensor1\",\n tag2:\"device2\"\n }],\n [{\n numValue: 20,\n randomValue: Math.random()*10,\n strValue: \"message2\",\n time: new Date(\"2015-12-28T19:41:14Z\").getTime()\n },\n {\n tag1:\"sensor1\",\n tag2:\"device2\"\n }]\n];\nreturn msg;","outputs":1,"noerr":0,"x":278,"y":335,"wires":[["f485378d.0b7ac8"]]},{"id":"68b911d9.9746f","type":"inject","z":"b061b303.4f9e5","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":104,"y":335,"wires":[["9555a67c.6aaa58"]]},{"id":"f485378d.0b7ac8","type":"influxdb out","z":"b061b303.4f9e5","influxdb":"eba91e98.1456e","name":"","measurement":"test","x":479,"y":334,"wires":[]}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/47d4c072a22ab706a76d7fe15065b92bfc7c93cf.png)

My payload :  
[{"channel":89,"type":"counter","unit":"null","value":435,"name":"hoursCell89"},{"channel":16,"type":"voltage","unit":"v","value":5.5,"name":"voltCell16"},{"channel":17,"type":"current","unit":"a","value":0.2,"name":"ampCell17"},{"channel":25,"type":"temp","unit":"c","value":29.4,"name":"tempTDS25"}]

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 July 2019 10:07 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/7 "2019-07-11T10:07:06Z")

</div>

> [@SuperNinja](#):
>
> this example looks like my payload :

It doesn't look the same format to me...

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [11 July 2019 10:33 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/8 "2019-07-11T10:33:11Z")

</div>

🤔 an array in array ?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 July 2019 10:56 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/9 "2019-07-11T10:56:21Z")

</div>

If you look at the function node in the `node-red-contrib-influxdb` example, and the way it's structured, that should give you an idea of how yours should be done.

```auto
[{"id":"eba91e98.1456e","type":"influxdb","z":"b061b303.4f9e5","hostname":"127.0.0.1","port":"8086","database":"aTimeSeries","name":"aTimeSeries"},{"id":"9555a67c.6aaa58","type":"function","z":"b061b303.4f9e5","name":"multiple readings","func":"msg.payload = [\n [{\n numValue: 10,\n randomValue: Math.random()*10,\n strValue: \"message1\",\n time: new Date(\"2015-12-28T19:41:13Z\").getTime()\n },\n {\n tag1:\"sensor1\",\n tag2:\"device2\"\n }],\n [{\n numValue: 20,\n randomValue: Math.random()*10,\n strValue: \"message2\",\n time: new Date(\"2015-12-28T19:41:14Z\").getTime()\n },\n {\n tag1:\"sensor1\",\n tag2:\"device2\"\n }]\n];\nreturn msg;","outputs":1,"noerr":0,"x":278,"y":335,"wires":[["f485378d.0b7ac8"]]},{"id":"68b911d9.9746f","type":"inject","z":"b061b303.4f9e5","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":104,"y":335,"wires":[["9555a67c.6aaa58"]]},{"id":"f485378d.0b7ac8","type":"influxdb out","z":"b061b303.4f9e5","influxdb":"eba91e98.1456e","name":"","measurement":"test","x":479,"y":334,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [11 July 2019 11:10 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/10 "2019-07-11T11:10:10Z")

</div>

it means that on the current form, InfluxDB can not read the sensors / data? I have to reformulate my payload?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 July 2019 11:16 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/11 "2019-07-11T11:16:27Z")

</div>

That's correct

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [11 July 2019 14:30 UTC](https://discourse.nodered.org/t/multiple-object-to-influxdb-issue/13132/12 "2019-07-11T14:30:25Z")

</div>

thanks for reply i'll do new msg.payload
