I'm logging energy usage data as a counter, which I would like to display as cumulative graphs that reset daily, as similarly asked here.
I can generate the cumulative value as follows:
SELECT mean("value") \
FROM "energy" \
WHERE $timeFilter \
GROUP BY time($__interval)
and the daily value as well:
SELECT max("value") \
FROM "energy" \
WHERE $timeFilter \
GROUP BY time(1d)
but I cannot subtract this or get this in one query, because the GROUP BY times are different.
(How) is this possible in influxdb? I've looked at INTEGRATE() but this haven't found a way to make this working.
The data looks like this (example limited to 1 day):
time value
---- ----
2018-12-10T17:00:00Z 7
2018-12-10T18:00:00Z 9
2018-12-10T19:00:00Z 10
2018-12-10T20:00:00Z 11
2018-12-10T21:00:00Z 13
2018-12-10T22:00:00Z 14
2018-12-10T23:00:00Z 15
2018-12-11T00:00:00Z 16
2018-12-11T01:00:00Z 17
2018-12-11T02:00:00Z 20
2018-12-11T03:00:00Z 24
2018-12-11T04:00:00Z 25
2018-12-11T05:00:00Z 26
2018-12-11T06:00:00Z 27
2018-12-11T07:00:00Z 28
2018-12-11T08:00:00Z 29
2018-12-11T09:00:00Z 31
2018-12-11T10:00:00Z 32
2018-12-11T11:00:00Z 33
2018-12-11T12:00:00Z 34
2018-12-11T13:00:00Z 35
2018-12-11T14:00:00Z 36
2018-12-11T15:00:00Z 37
2018-12-11T16:00:00Z 38
2018-12-11T17:00:00Z 39
I found a solution, it's quite simple in the end:
Note the fill(previous) is required to ensure kaifa_fill and kaifa overlap.
Example data:
Example graph: