I'm logging data from my gas meter using rtlamr
to InfluxDB 1.6.7. The gas meter periodically transmits its consumption in a running total, so it looks like this (for example):
100
100
101
101
102
105
105
It doesn't transmit at a fixed time interval. It just occasionally chooses to emit a value usually every few minutes.
When plotting this data in Grafana, how can I instead see total consumption grouped by hour rather than an ever-increasing running total? I've seen some examples, but they're for InfluxDB v2 which I can't use.
You can try the following InfluxQL query for a Grafana panel:
SELECT DIFFERENCE(last("consumption")) AS "hourly_consumption"
FROM "gas_meter"
WHERE $timeFilter
GROUP BY time(1h)
FILL(0)
It calculate the difference using DIFFERENCE function between each time interval grouped hourly. FILL function ensures any data is reported as zero consumption.