Not sure about what you expect but I’ll guess it’s the following:
Let’s say that now it’s 22:24 and I fetch the last 30min of data
I get data ranging from 21:54 to 22:24.
I use GROUP BY time(10m)
to group the data into intervals (each interval is grouped in the timestamp at the beginning of its time window)
Expectation:
having 3 groups
21:54, 22:04, 22:14
Reality:
I end up having 4 Groups
22:50, 21:00, 21:10, 21:20
When using “Group by time()” this is the behavior and you can’t change it, I’ve kind of thought about it only now, and I think that’s to make the results more standard and readable as using a non-fixed time reference will make comparisons, matching and other stuff a lot harder
On the good side, you don’t need it to satisfy your requirement.
You just need to get the last 10m of data and sum them, so just use
SELECT sum("diff_rain_mm") AS "sum_diff_rain_mm"
FROM "telegraf"."autogen"."emon_input" WHERE time > now() - 10m
Note: FILL(0)
has been removed as it won’t change the query output, if there are no points in the time interval you will get no output with or without it, if you need to force a 0 in there just use +0 sum("diff_rain_mm")+0