Home > Enterprise >  Using dates from node red to influxdb in Grafana
Using dates from node red to influxdb in Grafana

Time:08-17

I am collecting data from my electricity meter. Every day at 3AM I get a usage figure for the previous day which I send into InfluxDB via NodeRed.

The data is generated by a little Python file and consists of a JSON string:

{"UsageDate": "2022-08-14", "Usage": 9.622}

Each reading arrives during the day following UsageDate, so when I send it to InfluxDB it gets a timestamp which is actually a day late. I want to display this data as a bar chart/histogram in Grafana - but I don't know how to use the dates in UsageDate (which is stored in InfluxDB as a string at the moment) as the x-axis of my graph.

Can I persuade Grafana to use that date, or do I need to do something clever to make InfluxDB timestamp my data for the day it belongs to, rather than the day it arrives in InfluxDB.

CodePudding user response:

the solution is transformations. You need to do 2 things:

  1. Change the type to date: add transformation "Convert field type" to convert the field UsageDate to a time (check to give the correct format).
  2. Rename the field UsageDate to "Time" using a transformation "Organize fields". This will make it the x-Axis of a Time series panel.

Transformations in my configuration

  • Related