mblackstock / node-red-contrib-influxdb

Node-RED nodes to save and query data from an influxdb time series database
Other
64 stars 44 forks source link

specific tags for specific fields #101

Closed mtb999 closed 3 years ago

mtb999 commented 3 years ago

Hello, I'm trying to have a JSON format which I can specify tags for a specific fields

so the situation is for example we will have tags for place general and for each fields a specific tags

[ { "measurement": "noeudtest15", "tags": { "capteur": "bme280", "fields": { "temp": 5.5, "light": 678, "humidity": 51 } } } ]

Could someone try please to give me a right JSON example working on influxdb 2.0

mblackstock commented 3 years ago

The README should be able to help you get the payload format right.

If you're using the Batch node, then the format is as follows:

    {
        measurement: "alarm_sensor",
        fields: {
            proximity: 999,
            temp: 19.5
        },
        tags:{
            location:"home"
        },
        timestamp: new Date()
    }

Notice that the tags are separate from the fields, you cannot wrap fields in a tag object as you've done. The tags supplied are associated with the fields in the data record.

Using the output node, fields are in the first element of the array, and tags are in the second element. ​They are related to each other since they are in the same array.

e.g.

   ​[{
       ​intValue: '9i',
       ​numValue: 10,
       ​randomValue: Math.random()*10,
       ​strValue: "message1",
       ​time: new Date().getTime()-1
   ​},
   ​{
       ​tag1:"sensor1",
       ​tag2:"device2"
   ​}]

For more information on the data elements in InfluxDb 2.0, see Data Elements