8000 Add anchored and smoothed to vector selectors. by roidelapluie · Pull Request #16457 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add anchored and smoothed to vector selectors. #16457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roidelapluie
Copy link
Member
@roidelapluie roidelapluie commented Apr 18, 2025

This "PoC" is not finished nor optimized. It currently also returns data when there is only one point in the selector. It is not ready for use and just there to play around

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.

A complete design doc will follow.

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[5m] smoothed)

Other limitations

Does not work with Subqueries and Native Histograms.

@DmEye
Copy link
DmEye commented Apr 23, 2025

Hi @roidelapluie,

I have a question about increase(... anchored) behavior. You mentioned that increase(caddy_http_requests_total[5m] anchored) would be equivalent to caddy_http_requests_total - caddy_http_requests_total offset 5m (with counter reset handling).

From what I understand:

  • increase() uses extrapolation by default,
  • while the second approach caddy_http_requests_total - ... offset 5m does not

Does the anchored modifier change this behavior? I'm trying to calculate the exact counter increase without extrapolation, and the subtraction with account of counter reset method seems to fit better.

Could you clarify how anchored affects the calculation? Thanks in advance!

@roidelapluie
Copy link
Member Author

Design doc coming but shortly: anchored changes the underlying vector so that "increase" does not extrapolate. Therefore you have the result without extrapolation.

@roidelapluie
Copy link
Member Author

Proposal: prometheus/proposals#52

**This "PoC" is not finished not optimized. It currently also returns data when there is only one point in the selector. It is not ready for use and just there to play around**

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.

A complete design doc will follow.

*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[5m] smoothed)`

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0