How does mean aggregation works in influx

Dear Influx Experts,

I’ve created an API to fetch data from Influx to Excel. My API was successful and it gives me the data according to what is in the influx.
I have some issues (I don’t know if this is issue on influx or on my query side). So I tried to query "Select mean(value) from measurementName Where time >= StartTime and time <= EndTime Group by time(1m).
To be specific the range of time is to be 5 mins, so it’s like I am querying a time between, 12:05 PM to 12:10 PM, something like that.
So this is what the results look like: (please see image below, “Aggregated mean(5-10min with 1m interval”)

It seem’s right at this moment, and I have trust that Influx automatically calculate mean values every min. By the way, my values are changing every seconds.

So here’s the thing, so let say I’ve queried 12:05 PM to 12:10 PM with interval “1m” and get the mean, does the 12:05 PM result is the average values between 12:04 PM to 12:05 pm?
and 12:06 results is the average of 12:05 PM to 12:06 pm?
That is actually my understanding when querying aggregated functions (please correct me with this).

If my understanding is right, so I did some testing, I tried to query raw values between 12:04 PM to 12:05 PM and get all the raw values in there. So here is the result: (see image below: Raw values(4-5min) and Raw values (5-6min))

As you can see on the top, using the Excel function “=Average”, I get the results between 12:04 PM to 12:05 PM different values from InfluxDB. I also tried to query raw values of 12:05 PM to 12:06 PM and get the average values too, but it also has different values from influx mean queries.

Is my understanding on how influx compute the mean is right? because when I did the testing, the values are different, I hope I am wrong with this.

Hoping for your kind responds.

PS: Sorry I can only upload 1 image.

Thank you and stay safe.

Regards,

1 Like

Okay I found something, the 12:05 mean value is equal to average values between 12:05:00 PM to 12:05:59 PM.
So basically, my understanding was right, but the reference time is wrong.
So the result for the 12:06:00 PM mean will be the average values between 12:06:00 PM to 12:06:59 PM.

I just got confused since other database use to get the reference “back” the time but not the forward, for example the 12:06:00 pm mean is the result of average values between 12:05:00 PM to 12:05:59 PM.

Can we configure this to be that way ?

1 Like

Not sure how common other ways of referencing a time summary would be. One way of looking at it is that it’s truncating off the seconds portion from the time stamps, then aggregating/grouping/summarizing on those.

Still, if you have seen other systems that use the last/boundary timestamp as the “label” for the period, maybe worth asking if a new feature could be added to make that configurable.

Thanks! FixTestRepeat, highly appreciated your insight here.