Skip to content

feat(prometheus): Add minimum range interval based on scrape interval #4364

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

ChrisMcD1
Copy link
Contributor

Inspired by how Grafana does $__rate_interval, this adds the feature that the minimum range passed to Prometheus will be 4x the configured scrape interval. This allows users of 1 minutes scrape intervals to see metrics on the 30 minute and 1 hour time range, which is currently impossible.

For details of Grafana's implementation:
https://grafana.com/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/

@ChrisMcD1 ChrisMcD1 requested a review from a team as a code owner June 18, 2025 19:25
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 18, 2025
Inspired by how Grafana does `$__rate_interval`, this adds the feature
that the minimum range passed to Prometheus will be 4x the configured
scrape interval. This allows users of 1 minutes scrape intervals to see
metrics on the 30 minute and 1 hour time range, which is currently
impossible.

For details of Grafana's implementation:
https://grafana.com/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/

Signed-off-by: Chris McDonnell <chris.mcdonnell@tstllc.net>
@ChrisMcD1 ChrisMcD1 force-pushed the long-prometheus-scrape-interval branch from a4333ff to c1d2780 Compare June 18, 2025 19:28
@ChrisMcD1
Copy link
Contributor Author

Oh, just realized that this implementation doesn't quite work for larger time ranges. We only want to divide by the scaling factor for the smaller time ranges.

Perhaps a better idea would be to just decrease the number of data points when there is a longer scrape interval.

@ChrisMcD1 ChrisMcD1 marked this pull request as draft June 18, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant