# Influxdb node setting more values

**URL:** https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586
**Category:** General
**Created:** [24 June 2021 15:29 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586 "2021-06-24T15:29:55Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 15:29 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/1 "2021-06-24T15:29:55Z")

</div>

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:

```auto
  {
    "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

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

```

I actually only want the time, topic and value:

```auto
  {
    "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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 June 2021 15:47 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/2 "2021-06-24T15:47:41Z")

</div>

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

```auto
[
{  
  time: "the time ..",
  value: 1994
},
{
  topic: "Inverter/GridWatts"
}
]

```

---

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 15:54 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/3 "2021-06-24T15:54:08Z")

</div>

Thank you for the response.

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

```auto
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:

```auto
system_Total_load_power

```

This gives me in influx:

```auto
{
    "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:

```auto
{
    "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?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 June 2021 15:58 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/4 "2021-06-24T15:58:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 16:07 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/5 "2021-06-24T16:07:25Z")

</div>

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

> [@mynoderocks](#):
>
> So basically right now I am getting a flow from MQTT - Influx its a simple flow MQTT Topic --\> Influx
> 
> ```auto
> From MQTT Node: Topic: mysystem/total/load_power/state
> 
> ```
> 
> The value that outputs is a simple interger i.e. 23432

So how its storing it in influx:

 ![topics2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fdd71d41be1bbb16085c0f2b30fb1b22beba95b9.jpeg)

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):

 ![Topics](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d6e2a9bce0193448a3261c0c43d1fdcf5656a84c.jpeg)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 June 2021 16:13 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/6 "2021-06-24T16:13:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 16:18 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/7 "2021-06-24T16:18:49Z")

</div>

> [@Colin](#):
>
> which case they should be stored as two fi

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)

 ![topics2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fdd71d41be1bbb16085c0f2b30fb1b22beba95b9.jpeg)

and not like this

 ![Topics](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d6e2a9bce0193448a3261c0c43d1fdcf5656a84c.jpeg)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 June 2021 16:25 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/8 "2021-06-24T16:25:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 16:44 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/9 "2021-06-24T16:44:17Z")

</div>

> [@Colin](#):
>
> 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

---

<div class="post-metadata">

### Author: ![mynoderocks](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mynoderocks](https://discourse.nodered.org/u/mynoderocks)
#### Post date: [24 June 2021 18:02 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/10 "2021-06-24T18:02:08Z")

</div>

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

```auto
{
    "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?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 June 2021 19:51 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/11 "2021-06-24T19:51:26Z")

</div>

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

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

```

if you want fields and tags then

```auto
[
  {
    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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [23 August 2021 19:51 UTC](https://discourse.nodered.org/t/influxdb-node-setting-more-values/47586/12 "2021-08-23T19:51:51Z")

</div>

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