# Grafana + InfluxDB + Node-Red

**URL:** <https://discourse.nodered.org/t/grafana-influxdb-node-red/1453>\
**Category:** General\
**Created:** [8 July 2018 21:45 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453 "2018-07-08T21:45:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [8 July 2018 21:45 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/1 "2018-07-08T21:45:50Z")

</div>

Is it possible to get values from this graph?

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

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [8 July 2018 21:55 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/2 "2018-07-08T21:55:00Z")

</div>

Weird, I get:  
 ![11%20PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2e5003fcf1d6e465fd4a757730deb83dcec8f523.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [8 July 2018 22:09 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/3 "2018-07-08T22:09:26Z")

</div>

Are you storing numbers or strings to InfluxDB?

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [8 July 2018 22:29 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/4 "2018-07-08T22:29:20Z")

</div>

I don't know.  
I create my object like this:

```auto
 msg.payload={
                  TIME:context.get('time_tick')||0, 
               AMBIENT:context.get('ambient')||0,
               BREWBOX:context.get('brewbox')||0,
            BREWBUCKET:context.get('brewbucket')||0,
              SETPOINT:context.get('setpoint')||0,
                  HEAT:context.get('heat')||0,
                  COOL:context.get('cool')||0}

```

and send it to influxdb. They are all numbers.  
Can I specify a data type?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [8 July 2018 22:38 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/5 "2018-07-08T22:38:35Z")

</div>

Feed them into a debug node and check if they are numbers, I can't see how you are defining them as they are context variables.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 00:27 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/6 "2018-07-09T00:27:40Z")

</div>

You were right, I was sending text. Now to workout how to send numbers.  
Thanks,

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 02:41 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/7 "2018-07-09T02:41:02Z")

</div>

Thanks ghayne, this looks much better:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0bad1ca73a80da2b30316ec1adbcf3b83d021838.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [9 July 2018 10:06 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/8 "2018-07-09T10:06:32Z")

</div>

This will convert text to numbers:  
 ![22%20PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/82ec0824d32f7442d17644fdf2b75cc2b40ea5ea.png)

The $trim removes leading spaces.

---

<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:** [9 July 2018 11:22 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/9 "2018-07-09T11:22:58Z")

</div>

Since this is in a function node already I think it can done by using, for example,  
`AMBIENT:Number(context.get('ambient'))`  
or the equivalent when writing it to the context.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 15:16 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/10 "2018-07-09T15:16:40Z")

</div>

I convert C to F in a function just before the function I use to build my object. How I solved the text to number is on line 4.

```auto
var c = msg.payload;
var f;
f = (c*1.8)+32;
f.toFixed(2);
node.status({fill:"red",shape:"ring",text:f});
msg.topic = "ambient";
msg.payload = f;
return msg;

```

As the kids used to say, there must be a bazillion ways to do it.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [9 July 2018 15:33 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/11 "2018-07-09T15:33:25Z")

</div>

Well, the `toFixed(...)` function returns a number as a truncated/formatted string ... which I think is the opposite of what Colin is suggesting.

As for converting temperature scales, the "bazillion+1" way I like is to use a `range` node, configured to map from `0 .. 100` to `32 .. 212` -- fwiw

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 15:39 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/12 "2018-07-09T15:39:19Z")

</div>

I assume that will return a number, without fail. After living in a strict data type world js is a little squirrley for me.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [9 July 2018 15:41 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/13 "2018-07-09T15:41:16Z")

</div>

And here is thought JS meant "JavaScript" -- not _jittery squirrel_😉

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 15:43 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/14 "2018-07-09T15:43:07Z")

</div>

hahahaha! I like your version better. 🙂

---

<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:** [9 July 2018 16:10 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/15 "2018-07-09T16:10:07Z")

</div>

> [@Backup](#):
>
> f = (c\*1.8)+32;

The result of that will always be a number (except it could be NaN if it can't work it out). It will never be a string. As Shrikus says the the purpose of toFixed() is to convert a number to a string with the given number of digits (usually for display).  
I suggest not removing digits from values unless it is just for display. If you remove digits before saving in a database then you will never be able to see the value to full precision. Grafana allows you to specify precision when displaying values. Also don't remove precision if the value is going to a control loop, you just make it harder for the controller to work out what to do by not giving it all the information that is available.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [9 July 2018 18:25 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/16 "2018-07-09T18:25:04Z")

</div>

Almost there.  
I would like to change my power series from F to % and to 2 decimal points for all values in the window. I'm not sure how to do that since I didn't assign F to it. Secondarily I'd like to get the right Y axis to show power so I can scale it better.  
Any suggestions?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/53efd2724fb2b82c2b588762e05bd131fa49df87.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:** [9 July 2018 18:59 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/17 "2018-07-09T18:59:40Z")

</div>

You can have two y axes, one on the left and one on the right and assign each channel to one or the other. Setup in the Axes tab.  
None of mine have any unit information. Are you definitely just sending numeric values to influx. Put debug node on the input and check. Otherwise not sure where that is setup.  
Number of decimal places is setup on the Legends tab.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 01:06 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/18 "2018-07-10T01:06:22Z")

</div>

Got it.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/97b7fd77f6664d4b4e2525b60e77f6ab123643b4.png)

I have the retention set to 1d I think. That should be enough for a good graph.

---

<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:** [10 July 2018 06:53 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/19 "2018-07-10T06:53:48Z")

</div>

Great. You can remove the shading under the lines (if you want to) by setting Fill to 0 on the Display tab.

If that is real data using the ranged cool output as previously discussed (so only 5% of actual cool is available) and it needs virtually full power (ie 5%) to maintain the setpoint then I think you need to increase the max cool power a bit. Possibly 7.5%, otherwise it might not be able to maintain the setpoint if your ambient goes up any more, plus, as it is, it would presumably take a long time to cool down on startup from ambient.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 15:11 UTC](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453/20 "2018-07-10T15:11:47Z")

</div>

Yes, it is real data. The cool may be misleading. I didn't change the scale so 98% is actually 2% in a range of 0% to 5%. In the graph below "Power" is scaled from 0% to 5%. The scale on the graph should change once the 100% data passes 1d retention.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/45b4c9a35940962ab9479381d4dfe42d94daec8d.png)

Last night the temperatures were steady so I set the setpoint to 64F which was about 1F below the brewbucket temp. I think I saw how to expand the graph from 6 hours but now I can't find it.  
When I initially start a batch of beer it is just coming off the boil so the temperature, especially in summer, may be several degrees above the desired fermentation temp. My concern is that 5% or even 7.5% power may take to long to reach temp. The time between boil and fermentation temperature is a vulnerable time for infection and should be minimized, though in practice I've never lost a batch because of it.

[Next page](https://discourse.nodered.org/t/grafana-influxdb-node-red/1453.md?page=2)
