Influxdb node setting more values

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:

  {
    "time": "2021-06-24T14:37:49.495751604Z",
    "value": "2436"
  }

Using the influxdb out node.

What I want to do is store data a little differently, example

  {
    "time": "2021-06-24T14:38:39.367275164Z",
    "host": "yourmamma",
    "topic": "Inverter/GridWatts",
    "value": 1994
  }

I actually only want the time, topic and value:

  {
    "time": "2021-06-24T14:38:39.367275164Z",
    "topic": "Inverter/GridWatts",
    "value": 1994
  }

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

Thank you for the response.

So basically right now I am getting a flow from MQTT - Influx its a simple flow MQTT Topic --> Influx

From MQTT Node: Topic: mysystem/total/load_power/state

The value that outputs is a simple interger i.e. 23432

Then in the influxdb node I use:

system_Total_load_power

This gives me in influx:

{
    "time": "2021-06-24T14:37:49.495751604Z",
    "value": "2436"
  }

What I am trying to do is append some information in there that is stored in Influx:

{
    "time": "2021-06-24T14:38:39.367275164Z",
    "topic": "Inverter/GridWatts",
    "value": 1994
  }

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.

So this is a solar system (single system) with multiple values example(s)

  1. Inverter Load
  2. Solar Panel Production
  3. Grid Utilization
  4. Battery charge

Its all coming from a single system as topics on MQTT, however if I store it the way I am doing it now

So how its storing it in influx:

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)

and not like this

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.

No not supplying the time, influx is doing it automatically - thank you though you taught me something today

Just as a matter of interest, if I wanted to store more than just one value in the same row so:

{
    "time": "2021-06-24T14:38:39.367275164Z",
    "topic": "Inverter/GridWatts",
    "value": 1994
  }

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?

This is explained in the help text for the node. If you want multiple fields, with the time automatically inserted then something like

{
    "topic": "Inverter/GridWatts",
    "value": 1994
}

if you want fields and tags then

[
  {
    field1: value1,
    field2: value2,
    ...
  },
  {
    tag1: "tag1 value",
    tag2: "tag2 value,
    ...
  }
]

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.

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