Hello everyone,
I currently have a MariaDB table that looks like this. The left field is the date (in UNIX timestamp), the right are Wh from an energy meter (a new value is added every minute by a Python service) :
timestamp BASE
1620500943 11128308
1620501004 11128362 # (1 minute later)
1620501065 11128384 # (2 minutes later)
1620501126 11128396 # ...
1620501187 11128406
1620501248 11128416
1620501308 11128437
...
I was able to display a graph of the BASE value in Grafana without much issue. However, what I am now trying to do is to display on the graph a line that shows the difference between a value and the previous one, like this:
timestamp BASE
1620500943 0
1620501004 54
1620501065 22
1620501126 12
1620501187 10
1620501248 10
1620501308 21
...
I was really surprised to see that Grafana does not come with features which make that kind of calculation (last value minus second-to-last value) and create a new line with the result.
Eventually, what I am trying to do is display the difference between two values separated from 24 hours - therefore being also able to filter out the lines that I do not want, and make the calculation on the remaining lines.
timestamp BASE
1620501004 0
1620587404 23584 # (24 hours later)
What is the best way to achieve that?
- Does this feature actually exist in Grafana? (maybe I missed it)
- Is it possible to achieve some things with the SQL of MariaDB?
- If not, will switching to a system like InfluxDB or Prometheus will help?
- Eventually, for maximal configuration, it is possible to put some code between the data source and the graph (like a Python script) that will do all the filtering, calculation and aggregation work for us?