🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › basics
Querying basics | Prometheus
Syntax: <instant_query> '[' <range> ':' [<resolution>] ']' [ @ <float_literal> ] [ offset <float_literal> ] <resolution> is optional. Default is the global evaluation interval. Prometheus supports many binary and aggregation operators. These are described in detail in the expression language operators page. Prometheus supports several functions to operate on data. These are described in detail in the expression language functions page. PromQL supports line comments that start with #. Example:
🌐
Better Stack
betterstack.com › community › guides › monitoring › promql
The Beginner’s Handbook to PromQL | Better Stack Community
February 26, 2025 - node_cpu_seconds_total{mode="idle"} offset 1h @ 1732616754 # This is equivalent to node_cpu_seconds_total{mode="idle"} @ 1732616754 offset 1h · Both queries will retrieve data for node_cpu_seconds_total from 1 hour before the fixed timestamp 1732616754. Now that you have a basic idea of how to query your metrics data with PromQL, let's take a brief moment to understand its underlying structure and the key components of its grammar.
Discussions

Implement PromQL offset modifier for range vector in LogQL
https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier The offset modifier allows changing the time offset for range vectors in a query to support e.g. selective timeshift in Grafana More on github.com
🌐 github.com
2
October 20, 2020
promql - Prometheus "negative" offset - Stack Overflow
I am trying to draw a a barchart in Grafana with a prometheus datasource. My simple query looks as follows: max_over_time(energy_monitor_watthour_today[1d]) I have Grafana set to the interval of... More on stackoverflow.com
🌐 stackoverflow.com
prometheus - Difference between two metrics with time offset in PromQL - Stack Overflow
I have a metric (gauge) updated, which has module label that's set to a name of a module. Modules set it to UTC now after they've performed a successful "update" (whatever it means). One of the mod... More on stackoverflow.com
🌐 stackoverflow.com
prometheus - Avoiding multiple subqueries in PromQL with offset to get historic averages - Stack Overflow
I have a prometheus server that offers a long retention of 13 months. I want to find anomalies for the number of registrations my web app gets. My idea was to take a look at the number of registrat... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/prometheusmonitoring › dynamic promql offset values for dst
r/PrometheusMonitoring on Reddit: Dynamic PromQL Offset Values for DST
December 3, 2024 -

Hi All,

Some of our Prometheus monitoring uses 10-week rolling averages, which was set up a couple months ago, like so:

round((sum(increase(metric_name[5m])))
/
(
    (sum(increase(metric_name[5m] offset 1w)) +
    sum(increase(metric_name[5m] offset 2w)) +
    sum(increase(metric_name[5m] offset 3w)) +
    sum(increase(metric_name[5m] offset 4w)) +
    sum(increase(metric_name[5m] offset 5w)) +
    sum(increase(metric_name[5m] offset 6w)) +
    sum(increase(metric_name[5m] offset 7w)) +
    sum(increase(metric_name[5m] offset 8w)) +
    sum(increase(metric_name[5m] offset 9w)) +
    sum(increase(metric_name[5m] offset 10w))
) 
/10), 0.01)

This worked great, until US Daylight Saving Time rolled back, at which point the comparisons we are doing aren't accruate anymore. Now, after some fiddling around, I've figured out how to make a series of recording rules that spits out a DST-adjusted number of hours for the offset like so (derived from https://github.com/abhishekjiitr/prometheus-timezone-rules):

# Determines appropriate time offset (in hours) for 1 week ago, accounting for US Daylight Saving Time for the America/New_York time zone

(vector(168) and (Time:AmericaNewYork:Is1wAgoDuringDST == 1 and Time:AmericaNewYork:IsNowDuringDST == 1)) # Normal value for when comparison time and the current time are both in DST
or
(vector(168) and (Time:AmericaNewYork:Is1wAgoDuringDST == 0 and Time:AmericaNewYork:IsNowDuringDST == 0)) # Normal value for when comparison time and the current time are both outside DST
or
(vector(167) and (Time:AmericaNewYork:Is1wAgoDuringDST == 0 and Time:AmericaNewYork:IsNowDuringDST == 1)) # Minus 1 hour for when time has "sprung forward" between the comparison time and the current time
or
(vector(169) and (Time:AmericaNewYork:Is1wAgoDuringDST == 1 and Time:AmericaNewYork:IsNowDuringDST == 0)) # Plus 1 hour for when time has "fallen back" between the comparison time and the current time

The problem is: I can't figure out a way to actually use this value with the offset modifier as in the first code block above.

Is anyone aware if such a thing is possible? I can fall back to making custom recording rules for averages for each metric we're alerting on this way, but that's obviously a lot of work.

🌐
Logz.io
logz.io › home › blog › how to › an intro to promql: basic concepts & examples
An Intro to PromQL: Basic Concepts & Examples | Logz.io
September 2, 2023 - Critically, using the offset method will return results relative to a certain point in time. For instance, ask for counters up until two days ago in this PromQL example:
🌐
GitHub
github.com › grafana › loki › issues › 2785
Implement PromQL offset modifier for range vector in LogQL · Issue #2785 · grafana/loki
October 20, 2020 - https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier The offset modifier allows changing the time offset for range vectors in a query to support e.g. selective timeshift in Grafana
Author: grafana
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
When +Inf or -Inf are found in ... and offset value calculated will be NaN. deriv should only be used with gauges and only works for float samples. Elements in the range vector that contain only histogram samples are ignored entirely. For elements that contain a mix of float and histogram samples, only the float samples are used as input, which is flagged by an info-level annotation. This function has to be enabled via the feature flag --enable-feature=promql-experimen...
🌐
SigNoz
signoz.io › guides › essential promql cheat sheet - master prometheus queries
Essential PromQL Cheat Sheet - Master Prometheus Queries | SigNoz
November 29, 2024 - The offset modifier shifts the time frame of a query, helping you compare past and present metrics: ... This selects the value of http_requests_total from 1 hour ago. Subqueries let you perform advanced calculations over a range of time.
🌐
DEV Community
dev.to › sre_panchanan › decoding-promql-a-deep-dive-into-prometheus-query-language-4h23
Decoding PromQL: A Deep Dive into Prometheus Query Language - DEV Community
November 12, 2024 - PromQL allows for time shifting operations on Range Vectors, such as using the offset modifier to shift the time range, enabling comparison of values at different points in time.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 61796030 › difference-between-two-metrics-with-time-offset-in-promql
prometheus - Difference between two metrics with time offset in PromQL - Stack Overflow
Select "other" metrics with 10 minutes offset, so we always compare "main" update time with the latest "other" metric update time taken at now - 10m moment, which gives "main" module 10 minutes to do its work:
🌐
GitHub
github.com › prometheus › prometheus › issues › 6282
PromQL: Allow negative (i.e. "future") offset · Issue #6282 · prometheus/prometheus
November 6, 2019 - Currently these are parse errors: metric offset -5m sum_over_time(metric[1h:1m] offset -5m) I propose these should allow a negative offset and therefore allow offsetting a query to the future of where the evaluation time currently is. Th...
Author: prometheus
🌐
Prometheus
discuss.prometheus.io › promql
Offsetting by 1 year minus 1 day - PromQL - Prometheus Monitoring System
February 22, 2024 - Hi, I’m very much a beginner with PromQL. I have the following use case. I gather solar production data from Home Assistant via Prometheus to build charts in Grafana. One of the charts I have built shows the peak production per day as one curve, and the corresponding peak production the previous ...
🌐
YouTube
youtube.com › prometheus monitoring with julius | promlabs
PromQL Data Selection Explained | Selectors, Lookback Delta, Offsets, and Absolute "@" Timestamps - YouTube
In this video, I explain how Prometheus / PromQL data selection works in detail. I go into instant and range vector selectors, label matchers, the 5-minute l...
Published: May 22, 2023
Views: 13K
🌐
O'Reilly
oreilly.com › library › view › hands-on-infrastructure-monitoring › 9781789612349 › be1ee491-cab9-405f-a576-22f27b2eeb71.xhtml
The offset modifier - Hands-On Infrastructure Monitoring with Prometheus [Book]
May 31, 2019 - The offset modifier The offset modifier allows you to query data in the past. This means that we can offset the query time of an instant or range vector selector relative to the...
Authors: Joel BastosPedro Araújo
Published: 2019
Pages: 442
🌐
KodeKloud Notes
notes.kodekloud.com › promql › modifiers
Modifiers - KodeKloud
July 16, 2026 - Explains PromQL modifiers offset and @ to query and anchor historical metric values and ranges for debugging, incident analysis, and retrospective inspection.
🌐
Medium
valyala.medium.com › promql-tutorial-for-beginners-9ab455142085
PromQL tutorial for beginners and humans | by Aliaksandr Valialkin | Medium
September 15, 2023 - PromQL allows querying historical data and combining / comparing it to the current data. Just add offset to the query.
🌐
Chronosphere
chronosphere.io › home › an introduction to promql
An Introduction to PromQL | Chronosphere
April 2, 2025 - For example, to return metrics results from an hour ago, add offset and a time offset after a query: ... Generally you use PromQL to return a range vector to then use with a function to perform calculations on the resulting range of time series.