Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Prometheus DB calculate average value

I have following temperature values stored inside Prometheus DB (each minute):

4
7
11
52
97
19
95
89
43
19
. . .

Now, I would like to get average temperature in each 5 minute interval.

/api/v1/query_range?query=avg_over_time(current_temp[5m])&start=1475483802.739&end=1475498202.739&step=300&_=1475493021942

I get following data back:

"values":[[1475488602.739,"4"],[1475488902.739,"37.2"],[1475489202.739,"51"],[1475489502.739,"79.6"] . . .

I really can not relate these values (4, 37.2, 51, 79.6 ...) with average data. Can some one help me with this?

Thanks

Here are two example through Prometheus graphing tool:

Real data (1 minute interval)

Aggregated data

like image 358
Slaven Tomac Avatar asked Jul 27 '26 23:07

Slaven Tomac


1 Answers

Let me answer my own question, the thing is that with the query I gave here:

/api/v1/query_range?query=avg_over_time(current_temp[5m])&start=1475483802.739&end=1475498202.739&step=300&_=1475493021942

following happens:

Each 300 seconds (from step parameter), read current temperature five minutes before that (each point you have) and calculate average from that. Do this in timespan between 1475483802.739 and 1475498202.739.

More information here https://github.com/prometheus/prometheus/issues/2051

like image 110
Slaven Tomac Avatar answered Jul 30 '26 16:07

Slaven Tomac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!