Global Object > Influx DB

Hi all,

I was watching a youtube video where I saw parts of the code of a great idea I am trying to replicate.
Values streaming from MQTT create a Global Object with the value(s) so something to this effect (from MQTT)

Global object

GblObj.Value1 = msg.payload.value1
GblObj.Value2 = msg.payload.value2
GblObj.Value3 = msg.payload.value3
GblObj.Value4 = msg.payload.value4
GblObj.Value5 = msg.payload.value5

What then happens (the part I didnt see) is that global object is then saved into Influx DB 2.x.

My Questions:

  1. Could you pass a global object directly to a influx output node as a object via msg.payload?
  2. I assume it would store the global object as the specified measurement but with the _field(s) as the object properties?

Bucket: MyBucket
Measurement: MyMeasurement
The way it would translate into Influx Db (using the global Object above) would be
MyMeasurement with fields:

This would allow me to concatenate various values into one time stamp so when I query it I get the table stream to reflect for that timestamp all the relevant values?

You could pass the data from MQTT to InfluxDB without a global if you wanted to. But in general, yes, you can do that either via a request node or via a dedicated InflxuxDB node.

That is your choice.

Yes, if you want to.

1 Like

Do you mean could you use global.get() to fetch a reference to the object and then pass that in the payload to the influx node then yes.

It will store whatever structure you build and pass to global.set()

Are the values obtained from different sensors and so at slightly different times? If so then the generally recognised good practice is to send them individually to separate measurements in influx. As soon as you start trying to combine values from multiple sources into one measurement you come across problems such as what to do if one of the sensors is in a fault condition. It just adds significant complexity for no great gain.
If you did want to do that then probably a better way would be to use a Join node rather than global data. But my advise would be don't do it. Keep it simple and just send the data as it is received to Influx.

1 Like

Further to my post above, if getting all the values for a timestamp is one of the main reasons to do this then the fact that they are not all at the same time does not matter. In the query, ask for the last value at or before a timestamp and you will get what you want.

1 Like

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