Influxdb GroupBy time uses predefined intervals and does not start with the first timestamp

1.6k views Asked by At

I am using Influxdb to store some data representing requests being made to certain services. I want to calculate the number of requests done in one second in a time interval of 5 seconds (multiple requests might happen in one second). In order to achieve this I have written this query in order to obtain the amount of requests happening during 5 seconds time period select sum(Value) as RequestSum from Requests where group by time(5s) fill(0). The issue that I am facing is that instead of creating intervals starting with the first timestamp registered which in my case would look like 2020-10-16 14:09:13 it always starts with something ending in a number of seconds divisible by 5 like 2020-10-16 14:09:10.

The same case happens when I try to group by time(6s), when the first timestamp it starts grouping by is 2020-10-16 14:09:12.

Is there a way to force Influx to start grouping by from a certain timestamp and not one that seems predefined?

1

There are 1 answers

1
Ciprian Nazarie On

In the end I have managed to find the solution I had to add a where clause containing the start time and the end time and also the group by time(5s) had to be change into group by time(5s, starttime) making the query look something like select sum(Value) as RequestSum from Requests where time>=1605197046000ms and time<=1605197120000ms group by time(5s, 1605197046000ms) fill(0)