Hi all,
I am currently using the influxdb out node to write values coming from my MQTT queue. Works wonders. I have two questions though:
Right now its writing the value as:
If anyone could give me some insight on how to do this or simply just point me to a node that can do this, from the documentation of the default influxdb node I cant see (or not understanding) how to do this
I am not sure what you are asking. Are you asking how to remove the host property from msg.payload? If so then the Change node has an option to Delete msg.payload.host.
However, I think it likely that you want the topic to be a tag not a field, in which case you want, in msg.payload
[
{
time: "the time ..",
value: 1994
},
{
topic: "Inverter/GridWatts"
}
]
Which means I have data coming from MQTT but thats only the value (in the current example), I want to manually append / create the "topic" for that value.
Does that make it any clearer or did I confuse it even more?
What will the different topic values mean in the real world? If they are measuring different things then usually that would be handled using different Influx Measurements, one for each value you are measuring. On the other hand, if they are measuring the same thing but from different devices, maybe kitchen temperature and bedroom temperature for example, then they would go to the same measurement (maybe room_temperature) using a Tag with a value of "kitchen" to indicate which room it applies to.
but this is just values .... I want to store the topic per value
What I want it to do Is have the topic for the value I am sharing saved as well for each value being saved. Ill give you an example from a different system that stores directly to Influx (no node red):
That is not the efficient way to do it. You should not store, for example, the grid watts and voltage in the same measurement, you should use different Measurements. The exception would be if they are received from the device at the same moment, in which case they should be stored as two fields in the same measurement.
Ok I learnt something, I didn't know that. So if I understand you correctly each value should be stored as a separate measurement (for the corresponding measurement) -
So like this (which is correct)
Yes, unless they are received from whatever is providing the data in one transaction. Suppose for example that when you ask the inverter for data it gives you the watts, volts, etc all in one message. In that case you would put them in one measurement as multiple fields (watts, volts ..).
To store the values in multiple measurements you can leave the measurement blank in the influx node and pass it in msg.measurement, if I remember correctly. Check the help pane for the node.
Also, is the time that you are supplying the current time? In which case you don't need to provide it at all as influx defaults to using the current time when you add a record.
So where time is automatically added by influx, value I am getting from MQTT value output and then Topic either I manually specify it or from another input how would i do it with the influxdb output node? Or is there another node I use?
It is important to understand the difference between fields and tags. If you use a field where it should be a tag and then try to select based on the value of that field using something like select * from measurement where some_field = "some_value"
then it will be horribly slow once the database starts growing in size. Any column that you want to search on should be a tag.