PromQL: Time: offset and the @ Modifier
Offset looks at the same query at an earlier time. The @ modifier pins a query to one exact moment.
Requests five minutes ago
Offset 5m reads the counter as it stood five minutes back.
http_requests_total{job="shopsentry"} offset 5mGrowth in the last five minutes
Now minus five minutes ago is the growth in that window.
sum(http_requests_total{job="shopsentry"}) - sum(http_requests_total{job="shopsentry"} offset 5m)One exact moment with @
The @ modifier pins the query to a single timestamp.
http_requests_total{job="shopsentry"} @ 1794440973Example
sum(http_requests_total{job="shopsentry"}) - sum(http_requests_total{job="shopsentry"} offset 5m)Key points
- Offset shifts a query back in time by the amount you name.
- Use offset to compare now with five minutes ago.
- Offset works on instant vectors and on range vectors.
- The @ modifier fixes a query to one Unix timestamp.
- Use @ to ask what a series was worth at one exact second.
- A timestamp in @ is seconds since 1 January 1970.
- Offset and @ can sit in the same query.
In this example, the query takes the total requests now and subtracts the total five minutes ago. The difference is how many requests arrived in the last five minutes. The numbers are the real totals from the live ShopSentry lab.
Note
Offset can only look back as far as your stored data reaches.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What does offset 5m do to a query?