Now what I would like to do is to basically set the very first visible data point to 0 and adjust all the others so the last data point is the actual last value - the the actual start value.
This is my usecase:
I have a sensor which sends the total amount of rain it registered in millimeters. Now I would like to see how much it has rained over a given time period and how the speed changed, without having to subtract the start value in my head.
For the case you described, are you always measuring the rainfall over the same period (e.g. midnight to midnight)? If so, then I think just having a stat panel with sparkline showing TOTAL amount the mm of rain would be a more logical panel (rather than trying re-engineer the time series panel). Do you feel that would meet your needs?
no, it is the total since reboot, so theoretically always increasing. I don’t want a single stat but a time series showing how fast it increased. I would like to be able to tell my dashboard to show me the amount of rain since time x and how it changed over that range.
You have counter and you want to have rate of change - typical use case for DERIVATE() or better for NON_NEGATIVE_DERIVATIVE() (because negative rate when sensor is restared doesn’t make sense) influxDB function.
No, you don’t need a time parameter. Linked InfluxDB manual is your friend:
The unit argument is an integer followed by a duration literal and it is optional. If the query does not specify the unit , the unit defaults to the GROUP BY time()
Query:
SELECT
NON_NEGATIVE_DERIVATIVE(counter_field)
FROM measurement
WHERE $timeFilter
GROUP BY time($__interval)
thank you, this works. However it is not very accurate.
The difference in the actual data is 3.9, but the cumulative sum of the rate is only 2.02
What could be the cause of that?
This is the query now:
SELECT cumulative_sum(non_negative_derivative(mean("value"))) *0.48352 FROM "bed_wall_precipitation_counts" WHERE $timeFilter GROUP BY time($__interval) fill(none)
what you require may be achieved with the influx db DIFFERENCE function.
The grafana difference function is only the difference between the last and first value in the array.
what you require is the difference value between each array value and this may be done using the influx db DIFFERENCE function.
the derivative will not work well in your case as the time step is not the same and the values have very small incremental change hence the cumulative error you are getting/seeing.