offset
Input Stack:
|
⇨ | Output Stack:
|
Shift the time frame used when fetching the data to look at a previous interval. This is commonly used for comparative analysis like day-over-day, week-over-week, or year-over-year comparisons by overlaying current and historical data.
Warning
Streaming Limitations: Offset cannot be used with streaming execution of queries. For real-time change detection over short intervals, consider using the delay operator instead.
Info
Deprecated Variant: There is a deprecated List[Duration]
variant that only modifies
the presentation layer. It cannot be used with mathematical operations and should be avoided.
Parameters¶
- expr: The time series expression to apply the time offset to
- duration: The time duration to shift backward (e.g.,
1w
,1d
,PT1H
)
Duration Formats¶
- Simple format:
1w
(1 week),1d
(1 day),1h
(1 hour) - ISO 8601 format:
PT1H
(1 hour),P1D
(1 day),P1W
(1 week)
Examples¶
Week-over-week comparison (show current and previous week):
Before | After | Combined |
name,sps,:eq, (,name,),:by | name,sps,:eq, (,name,),:by, 1w,:offset | name,sps,:eq, (,name,),:by, :dup, 1w,:offset |
Hour-over-hour comparison using ISO 8601 duration:
Before | After | Combined |
name,sps,:eq, (,name,),:by | name,sps,:eq, (,name,),:by, PT1H,:offset | name,sps,:eq, (,name,),:by, :dup, PT1H,:offset |
Common Use Cases¶
- Trend analysis: Compare current metrics with historical baselines
- Anomaly detection: Identify deviations from typical patterns
- Performance regression: Detect when current performance differs from past
- Seasonal comparison: Compare metrics across similar time periods