Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAverage value not calculated right? #2051
Comments
This comment has been minimized.
This comment has been minimized.
|
Can you indicate how the value is wrong, what value you expected and what the input data is? |
brian-brazil
added
the
kind/question
label
Oct 3, 2016
This comment has been minimized.
This comment has been minimized.
|
So, as you can see from the screen shot, last value is 60, the value before that it is 67. How is the average 66.4166 (based on the response screenshot)? I expected to be last value or the average of last two values (not still sure how Prometheus is calculating it) |
This comment has been minimized.
This comment has been minimized.
|
@slavede What you see in the graph are 60s-spaced interpolated query evaluation points. Not the raw samples in the database. The range vector that you input into
Of course, then @brian-brazil might still say that one shouldn't average over temperatures at all ;) |
This comment has been minimized.
This comment has been minimized.
|
Cool, thanks, nice explanation. Then, if I do: /api/v1/query_range?query=avg_over_time(current_temp[5m])&start=1475483802.739&end=1475498202.739&step=600&_=1475493021942 This would do the following: Each 600 seconds read current temperature for the last 5 minutes (every point you have) and calculate average temperature, and do this between 1475483802.739 and 1475498202.739? |
slavede
changed the title
Average value not calculated right
Average value not calculated right?
Oct 4, 2016
This comment has been minimized.
This comment has been minimized.
|
The language in your last sentence is slightly ambiguous, so depending on what exactly you mean, it's correct or incorrect :) Let me rephrase it: starting at timestamp 1475483802.739 and ending at timestamp 1475498202.739, the query "avg_over_time(...)" gets executed at regular instants that are 600 seconds apart. At every such instant, Prometheus calculates the average over all sample values (within each series) stretching back 5 minutes from that instant. This produces the output sample value for that instant. Note that some samples are skipped completely, since your time averaging time window is 5 minutes, but your query resolution step is 10 minutes (600s). |
This comment has been minimized.
This comment has been minimized.
|
Yeah, that's what I meant :). Thanks, it's clear explanation. And yes, they are skipped, I've just put it there as an example. Thank you very much for your help. |
slavede
closed this
Oct 5, 2016
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 24, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
slavede commentedOct 3, 2016
•
edited
What did you do?
Tried to get average value
What did you expect to see?
Correctly calculated value
What did you see instead? Under which circumstances?
Wrong value
Environment


Linux 2.6.32-358.el6.x86_64 x86_64
Prometheus version:
build user: root@3e392b8b8b44
build date: 20160916-11:36:30
go version: go1.6.3
Alertmanager version:
insert output of
alertmanager -versionhere (if relevant to the issue)Prometheus configuration file:
Similar question here:
http://stackoverflow.com/questions/39831998/how-does-prometheus-db-calculate-average-value