# Passing 2 values into single influxdb node

**URL:** https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899
**Category:** General
**Created:** [19 May 2021 09:52 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899 "2021-05-19T09:52:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![subwayfootlong](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subwayfootlong/32/42037_2.png) [@subwayfootlong](https://discourse.nodered.org/u/subwayfootlong)
#### Post date: [19 May 2021 09:52 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/1 "2021-05-19T09:52:30Z")

</div>

Hello, in the influxdb node, you have to manually type the measurement name.  
I am able to extract the value and the value name from an array.

I was wondering if I could also pass the value name into the influxdb node thus not requiring manual input on the measurement name.

---

<div class="post-metadata">

### Author: ![Simon01011](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Simon01011](https://discourse.nodered.org/u/Simon01011)
#### Post date: [19 May 2021 11:40 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/2 "2021-05-19T11:40:43Z")

</div>

Welcome subwayfootlong!

Do you know this thread?

> [@Write many values for the same time with nodered in influxdb](https://discourse.nodered.org/t/write-many-values-for-the-same-time-with-nodered-in-influxdb/44718):
>
> With the standard influx node, if I pass for (let i=0; i\<sensors.length; i++) timea.push(new Date().getTime()+i); // microsecsec from 00:00 1/1/1970 influxa.push({time: timea[0], field: sensors[7].value, tag: sensors[7].name }); influxa.push({time: timea[1], field: sensors[5].value, tag: sensors[5].name }); Where timea and influxa are empty arrays when the node starts. The influx node complains that error "Error: A 400 Bad Request error occurred: …

---

<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: [19 May 2021 13:43 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/3 "2021-05-19T13:43:37Z")

</div>

> [@subwayfootlong](#):
>
> I was wondering if I could also pass the value name into the influxdb

You can pass the measurement name in the message. Read the help text for the influx node.

---

<div class="post-metadata">

### Author: ![subwayfootlong](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subwayfootlong/32/42037_2.png) [@subwayfootlong](https://discourse.nodered.org/u/subwayfootlong)
#### Post date: [20 May 2021 06:58 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/5 "2021-05-20T06:58:26Z")

</div>

Ok maybe I'm looking into this all wrongly.  
Here is the json format of what the sensor is outputting

> [{"name":"BRTC CISS Sensor 004\_Humidity","description":"","unit":"% rH","values":[{"value":60.96,"timestamp":"2021-05-20T06:27:14.265Z"}]}]

Currently, I'm using a function node to extract the value from the array and connected it to the influxdb output node to upload it.

> value=msg.payload[0].value[0].value;  
> msg.payload=value;  
> return msg;

But because of this code, I have to manually set the measurement name in the influxdb output node.

What I want is to send both the measurement name and the value so that I dont have to manually set the measurement name.

From @Colin 's reply, I read the help text and that msg.measurement should contain the measurement name so I edited my code to

> value=msg.payload[0].value[0].value;  
> name=msg.payload[0].name;  
> msg.payload=value;  
> msg.measurement=name;  
> return msg;

However I get

> "Error: A 400 Bad Request error occurred:{"error":"unable to parse 'BRTC CISS Sensor 004\_Humidity value=60.96': invalid field format"}

Am I doing everything wrongly?

---

<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: [20 May 2021 08:22 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/6 "2021-05-20T08:22:49Z")

</div>

Whenever you have an unexpected error from a node the first thing to do is to connect a debug node showing what is going into the node. So connect a debug node to the output of your function and set it to Show Complete Message and check what it shows.  
Screenshot it here if you think it looks ok.  
What influx node are you using?

---

<div class="post-metadata">

### Author: ![subwayfootlong](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subwayfootlong/32/42037_2.png) [@subwayfootlong](https://discourse.nodered.org/u/subwayfootlong)
#### Post date: [20 May 2021 08:53 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/7 "2021-05-20T08:53:53Z")

</div>

![Screenshot 2021-05-20 165147](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c766aa011969fba8bfbdd02bb85fdd63a882a22.png)  
I am using the influxdb out node from the node-red-contrib-influxdb pallete

---

<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: [20 May 2021 09:52 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/8 "2021-05-20T09:52:08Z")

</div>

Does it work if you use a measurement name without spaces?

What version of influxdb are you using?

---

<div class="post-metadata">

### Author: ![subwayfootlong](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subwayfootlong/32/42037_2.png) [@subwayfootlong](https://discourse.nodered.org/u/subwayfootlong)
#### Post date: [21 May 2021 05:51 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/9 "2021-05-21T05:51:38Z")

</div>

You were right!  
The measurement name cant have spaces....  
I totally forgot about the fundamentals.  
Thanks Colin

---

<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: [21 May 2021 09:15 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/10 "2021-05-21T09:15:58Z")

</div>

> [@subwayfootlong](#):
>
> The measurement name cant have spaces

In fact I believe that you _should_ be able to have spaces in the measurement name, but Influx has been a bit flaky in the past with them (perhaps even in v2.0, I don't know). I just don't use spaces, using underscore instead.

---

<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: [4 June 2021 09:16 UTC](https://discourse.nodered.org/t/passing-2-values-into-single-influxdb-node/45899/11 "2021-06-04T09:16:31Z")

</div>

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