# Using a variable within an influxDB node

**URL:** <https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474>\
**Category:** General\
**Created:** [12 November 2022 00:15 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474 "2022-11-12T00:15:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![itcouldbeL](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@itcouldbeL](https://discourse.nodered.org/u/itcouldbeL)\
**Post date:** [12 November 2022 00:15 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/1 "2022-11-12T00:15:48Z")

</div>

Hi again, I'm trying to build a simple flow which will ping a set of IP addresses and send an alert if there is a failed ping.

Part of my flow will check influxdb but I need the 'measurement' to be variable. in the screenshot below, 'variable' needs to be the value of msg.ping.name but I can't work out how to do it.

I'm looking forward to any advice, thank you!

P.S I hope this is coherent enough. I'm very tired when writing this!

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea4afd32dda05d92ebcc6e1a1f5bfdee6e5aa8d6.png)

---

<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:** [12 November 2022 07:15 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/2 "2022-11-12T07:15:45Z")

</div>

If you are using node-red-contrib-influxdb you can specify the Measurement in msg.measurement. Alternatively use a Template node to build the query and pass that in.

---

<div class="post-metadata">

**Author:** ![itcouldbeL](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@itcouldbeL](https://discourse.nodered.org/u/itcouldbeL)\
**Post date:** [12 November 2022 11:46 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/3 "2022-11-12T11:46:52Z")

</div>

Hi, yes I am and I've used msg.measurement for the influxdb OUT which works great, but the influxdb IN seems to work in a completely different way where it needs a query text (see screenshot)

msg.measurement doesn't work. on the IN node sadly.

I'v tried setting up the below template, and then deleting all the query from the InfluxDB IN node, but I get a 'no query' error.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/829d990848a618abd9e7be0eb5502e892f7730e3.png)

---

<div class="post-metadata">

**Author:** ![itcouldbeL](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@itcouldbeL](https://discourse.nodered.org/u/itcouldbeL)\
**Post date:** [12 November 2022 12:24 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/4 "2022-11-12T12:24:38Z")

</div>

Just a little update. I've manmaged to work out how to use the template node to pass the query over (The little tip about using msg.query only showed up when I deleted all of the existing query) so I'm a lot closer! I've still not managed to pass the measurement variable in but I feel a lot closer. I'll update as I go.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc557fc52bac64a27e3e0799fa91acc415df5ee2.png)

---

<div class="post-metadata">

**Author:** ![itcouldbeL](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@itcouldbeL](https://discourse.nodered.org/u/itcouldbeL)\
**Post date:** [12 November 2022 13:04 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/5 "2022-11-12T13:04:03Z")

</div>

SUCCESS! The syntax got me, but I'm still very new to this. Thanks for your help 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a433e37bb95bbfd4fcc538c0a358ad840bb6a18.png)

---

<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:** [12 November 2022 13:16 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/6 "2022-11-12T13:16:56Z")

</div>

It is the fact you had `msg.measurement` that was the problem, not the triple braces.

---

<div class="post-metadata">

**Author:** ![itcouldbeL](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@itcouldbeL](https://discourse.nodered.org/u/itcouldbeL)\
**Post date:** [12 November 2022 17:48 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/7 "2022-11-12T17:48:14Z")

</div>

the triple braces are because some names have none alphanumeric characters

---

<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:** [12 November 2022 21:20 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/8 "2022-11-12T21:20:57Z")

</div>

Good point, you should indeed use triple braces.

---

<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:** [11 January 2023 21:21 UTC](https://discourse.nodered.org/t/using-a-variable-within-an-influxdb-node/70474/9 "2023-01-11T21:21:42Z")

</div>

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