prometheus/promql/parser
Julien 4199c2f45a
Add anchored and smoothed to vector selectors. (#16457)
* Add anchored and smoothed to vector selectors.

This adds "anchored" and "smoothed" keywords that can be used following a matrix selector.

"Anchored" selects the last point before the range (or the first one after the range) and adds it at the boundary of the matrix selector.

"Smoothed" applies linear interpolation at the edges using the points around the edges. In the absence of a point before or after the edge, the first or the last point is added to the edge, without interpolation.

*Exemple usage*

* `increase(caddy_http_requests_total[5m] anchored)` (equivalent of *caddy_http_requests_total - caddy_http_requests_total offset 5m* but takes counter reset into consideration)
* `rate(caddy_http_requests_total[step()] smoothed)`

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* Update docs/feature_flags.md

Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com>

* Smoothed/Anchored rate: Add more tests

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* Anchored/Smoothed modifier: error out with histograms

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

---------

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
2025-09-25 11:34:59 +02:00
..
posrange Add a note about PositionRange values 2025-08-13 17:57:40 +01:00
ast.go Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
functions.go feat(promql): add first_over_time and ts_of_first_over_time 2025-09-02 10:24:31 +12:00
generated_parser.y Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
generated_parser.y.go Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
lex.go Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
lex_test.go Merge pull request #16249 from roidelapluie/arythmetics 2025-04-22 10:17:41 +02:00
parse.go Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
parse_test.go Apply analyzer "modernize" to the whole codebase 2025-08-27 14:48:41 +02:00
prettier.go [PERF] PromQL: Replace some Sprintf with bytes.Buffer 2025-08-21 11:38:05 +01:00
prettier_rules.md Adds support for prettifying PromQL expression (#10544) 2022-07-07 18:13:36 +05:30
prettier_test.go Move calculation to the engine 2025-04-03 10:56:02 +02:00
printer.go Add anchored and smoothed to vector selectors. (#16457) 2025-09-25 11:34:59 +02:00
printer_test.go [TESTS] PromQL: Add BenchmarkExprString 2025-08-21 11:05:38 +01:00
value.go promql: use explicit type declare instead of string. (#7716) 2020-08-02 09:57:38 +01:00