What does the `offset` modifier do?
IntermediateConceptPromQL & Recording Rules
Answer
offset shifts the evaluation time back for that selector, useful for comparisons with the past:
sum(rate(http_requests_total[5m]))
/
sum(rate(http_requests_total[5m] offset 1w))
This is week-over-week traffic ratio. offset must come right after the selector or range. Negative offsets (offset -1h) are allowed. The related @ modifier pins evaluation to an absolute time: http_requests_total @ 1730000000.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate