Skip to content
16 changes: 16 additions & 0 deletions proposals/0052-extended-range-selectors-semantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@ increase(http_requests_total[5m] anchored)
- Improved composability across range boundaries
- Ensuring observed values are never skipped due to alignment issues

**Composability as the additive property**

The "composability across range boundaries" use case above is the *additive* property of `anchored`-mode `increase` (and equivalently `rate` and `delta`). This invariant is what makes anchored `increase` composable: splitting a wider range into adjacent sub-ranges and summing the results gives the same answer as asking for the wider range directly — and it does this for any possible sub-ranges.

For any series `m` and timestamps `T₀ < T₁ < T₂` with `r₁ = T₁ − T₀` (≤ lookback delta) and `r₂ = T₂ − T₁`:

```
increase(m[r₁] anchored) @ T₁
+ increase(m[r₂] anchored) @ T₂
= increase(m[r₁ + r₂] anchored) @ T₂
```

This equality is exact: the left-open / right-closed range membership `(start, end]` along with the separate lookback anchor at `start` ensure that the boundary sample at `T₁` is "last in the earlier range" and "anchor of the later range" — rather than double-membership — so its delta is counted exactly once. The partial-dataset illustration below (where two adjacent time windows individually over- or under-estimate, but together capture the total increase of 11) is this property in action.

This guarantee has practical consequences worth documenting: alerts, recording rules, and dashboards can freely re-window without numerical drift, including across irregular scrapes. See [prometheus/prometheus#18679](https://github.com/prometheus/prometheus/issues/18679) for the precise statement and proposed invariant tests covering uniform, off-cadence, and partial-dataset cases.

**Anchored increase and complete dataset**

![](../assets/2025-04-04_extended-range-selectors-semantics/anchored-increase-complete.png)
Expand Down