Skip to main content
Previously, the queries we’ve run returned the current (most recent) value of a metric.
A dark-themed presentation slide titled "Offset Modifier" showing the text "When performing a query, it returns the current value of a metric," with the word "current" highlighted. A small "© Copyright KodeKloud" appears in the bottom left.
Often you need a metric’s value from the past — for example, five or ten minutes ago, or a few days back after an outage. Prometheus provides modifiers to anchor queries to different points in time. The two most useful modifiers are:
  • offset — shift the result relative to “now” (or relative to a specified timestamp).
  • @ (at) — request the value at an exact timestamp.
Below are concise explanations and practical examples to help you use them correctly.

offset — read values from the past

The offset modifier reads metric values from some time before the evaluation time. For example:
This returns the value of node_memory_Active_bytes{instance="node1"} as it was 5 minutes ago. You can express durations with standard time-unit suffixes (see the image below for a quick visual reference).
A table titled "Time Units" showing suffixes and their meanings: ms = milliseconds, s = seconds, m = minutes, h = hours, d = days, w = weeks, y = years (365 days).
Common suffixes: Examples:
  • offset 5d — five days ago
  • offset 2w — two weeks ago
  • offset 90m or offset 1h30m — one and a half hours ago

@ (at) — query a specific timestamp

Use @ to evaluate a query at an exact time. The timestamp can be a Unix timestamp (seconds since the epoch) or an RFC3339 timestamp. Example with a Unix timestamp:
This returns the metric’s value at the second 1663265188.

Combining @ and offset

You can combine @ and offset. Prometheus interprets the @ timestamp as the reference point and then applies the offset relative to that reference. The order of the modifiers does not change the result. Examples:
@ sets the evaluation anchor; offset shifts relative to that anchor. You can use either Unix or RFC3339 timestamps with @. The order of @ and offset makes no difference to the final evaluation time.
When Prometheus shows numeric results for instant-vector queries with these modifiers, you may see scalar-like sample values such as 22259302.

Using @ and offset with range vectors

Range vectors select a time window of samples. For example, node_memory_Active_bytes{instance="node1"}[2m] normally selects two minutes of data up to the current time. When you combine range vectors with @ and/or offset, the entire time window is anchored relative to the specified time. Examples:
In the second example, Prometheus returns samples from 12 minutes before the @ timestamp up to 10 minutes before it — a two-minute window shifted 10 minutes earlier.

Practical uses

  • Debug incidents by inspecting metric values at specific past times.
  • Build dashboards that compare current values to past values (e.g., “value 1 hour ago”).
  • Create alerting rules that reference a previous evaluation point for anomaly detection or trend comparisons.

References

Watch Video