Multiple object to Influxdb issue

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
You can see in this example the mqtt CAYENNE 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 :


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:

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

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 ... :roll_eyes:

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.

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.

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

Are you using the correct format to post data to influx?
Please have a look at the examples given in node-red-contrib-influxdb and compare with your format.

@Paul-Reed :

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

[{"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":[]}]

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"}]

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

:thinking: an array in array ?

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.

[{"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":[]}]

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

That's correct

thanks for reply i'll do new msg.payload