-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# How Prometheus's query steps (aka query resolution) work | ||
|
||
Source: <https://utcc.utoronto.ca/~cks/space/blog/sysadmin/PrometheusQuerySteps> | ||
|
||
In general, when you write a simple Prometheus PromQL query, it is evaluated at some point in time (normally the current instant, unless you use [offset modifier](https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier)). This includes queries with [range vector selectors](https://prometheus.io/docs/prometheus/latest/querying/basics/#range-vector-selectors); the range vector selector chooses how far back to go from the current instant. This is the experience you will get in Prometheus's expression browser console. | ||
|
||
In a Prometheus graphing query, there is a range of time you're covering and the there is the *query step*. How Prometheus appears to work is that your expression is repeatedly evaluated at instants throughout the time range, starting at the first instant of the time range and then moving forward by the query step until things end. The query step or query resolution (plus the absolute time range) determines how many points you will get back. The HTTP API documentation for range queries makes this more or less explicit in its example; in a query against a 30-second range with a query step of 15 seconds, there are three data points returned, one at the start time, one in the middle, and one at the end time. | ||
|
||
**A range query's query step is completely independent from any range durations specified in the PromQL expression it evaluates**. If you have 'rate(http_requests_total[5m])', you can evaluate this at a query step of 15 seconds and Prometheus doesn't care either way. What happens is that every 15 seconds, you look back 5 minutes and take the rate between then and now. It is rather likely that this rate won't change much on a 15 second basis, so you'll probably get a smooth result. On the other hand, if you use a very large query step with this query, you may see your graphs go very jagged and spiky because you're sampling very infrequently. You may also get surprisingly jagged and staircased results if you have very small query steps. |