#17060·prometheus

Offset should not be allowed before a range vector selector

Author: makasimCreated Aug 19, 2025Updated Sep 15, 2026
Labelskind/bugcomponent/promql

What did you do?

I’d like to clarify whether defining the '[' <range> ':' [<resolution>] ']' after offset is considered expected and valid PromQL syntax.

What I checked

I reviewed PromQL basics and subquery docs, and promqltest testdata. All examples I found show range defined before offset, not after. I couldn’t find a documented case of the opposite order. It is hard to reason validity without a formal specification.

Is the syntax with range/resolution after offset (expr offset X[range]) expected and valid? If so, how should it behave compared to the canonical expr[range] offset X form?

What did you expect to see?

I would expect queries that specify the range after the offset to be invalid.

What did you see instead? Under which circumstances?

From my observations:

  • demo_counter_total[2m:10s] offset 5m – works
  • demo_counter_total[2m] offset 5m – works
  • demo_counter_total offset 5m[2m] produces an error: "invalid parameter "query": 5:29: parse error: no offset modifiers allowed before range"
  • demo_counter_total offset 5m[2m:10s] – works

With functions:

  • rate(demo_counter_total[2m:10s] offset 5m) – works
  • rate(demo_counter_total[2m] offset 5m) – works
  • rate(demo_counter_total offset 5m[2m]) produces an error: "invalid parameter "query": 5:29: parse error: no offset modifiers allowed before range"
  • rate(demo_counter_total offset 5m[2m:10s]) – works

System information

No response

Prometheus version

Prometheus configuration file

Alertmanager version

Alertmanager configuration file

Logs