Skip to content
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

Prometheus: Add hints for native histograms #87017

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bohandley
Copy link
Contributor

@bohandley bohandley commented Apr 28, 2024

Fixes #86388

What is this feature?

When a user selects a native histogram, a hint or hints should be provided indicating they have selected a native histogram and providing functions for that metric.

This PR provides hints that allow a user to add 6 functions to the query builder from a native histogram hint

histogram_avg(rate(${expression}[$__rate_interval]))
histogram_fraction(0,0.2,rate(${expression}[$__rate_interval]))
histogram_count(rate(${expression}[$__rate_interval]))
histogram_sum(rate(${expression}[$__rate_interval]))
histogram_stddev(rate(${expression}[$__rate_interval]))
histogram_stdvar(rate(${expression}[$__rate_interval]))
Screenshot 2024-04-28 at 10 28 21 PM

The code editor can only show one hint at a time so until we refactor that, we show that the metric is a native histogram and provide the hint to use histogram_avg with the rate function.

Screenshot 2024-04-28 at 9 01 34 PM

Fixes #86388

Why do we need this feature?

Native histograms are being released in Mimir in the next month and this is part of the GA strategy.

Who is this feature for?

For users who have enabled native histograms.

Special notes for your reviewer:

TESTING!!!!!!

  1. Use this repository which creates native histograms BUT MAKE SURE YOU UPDATE THE FOLLOWING
  • use Prometheus version 2.51.0 int he docker compose file or you won't be able to test all the functions
services:
  prometheus:
    image: prom/prometheus:v2.51.0
  • update the docker compose Grafana image to use the tag v11.1.0-69868 or later you will have a bad time because you'll need the new parser if you switch between query builder and code editor.
  • If you don't want to update the grafana image just run Grafana locally with main and create a data source from the prometheus-native-histogram prometheus datasource or add this datasource yaml file.
# config file version
apiVersion: 1

# list of datasources to insert/update depending
# what's available in the database
datasources:
  # <string, required> name of the datasource. Required
  - name: Prometheus-native-histogram
    # <string, required> datasource type. Required
    type: prometheus
    # <string, required> access mode. proxy or direct (Server or Browser in the UI). Required
    access: proxy
    # <int> org id. will default to orgId 1 if not specified
    orgId: 1
    # <string> custom UID which can be used to reference this datasource in other parts of the configuration, if not specified will be generated automatically
    uid: prometheus
    # <string> url
    url: http://prometheus:9090
  1. Now you should have a data source that has a native histogram. The native histogram is named rpc_durations_native_histogram_seconds.

  2. When you select this in the query builder you will get six query hints (6 functions).

  3. When you select this metric in the code editor you will get one hint because the code editor only displays one hint. We need to fix that or create an issue to fix this.

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@itsmylife
Copy link
Contributor

A hint:
Please make sure you disable promQLScope feature flag.

Copy link
Contributor

@itsmylife itsmylife left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even I add a the recommended histogram function it keeps suggesting me to add the histogram functions.

image

Also layout is not the same with your image on my machine. I think some stuff has been changed in time.

Copy link
Contributor

@NWRichmond NWRichmond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also encountering some issues:

demo.prometheus.native.histogram.hints.mov

@zhehao-grafana
Copy link

Thanks, Ismail and Nick, for the review! Can I assume Brenden will be the one fixing these issues when he returns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show function hints when selecting a native histogram
4 participants