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: Default support labels value endpoint with match param when prom type and version not set #84778

Conversation

bohandley
Copy link
Contributor

Fixes #81059

What is this?

When a user creates a new Prometheus data source in Grafana and does not set the type and version, we will support the labels values endpoint with match parameter (labelsMatch) over the series endpoint.

/api/v1/label/__name__/values?match[]=<series_selector>

Special note: The metrics browser still relies on the series endpoint and that will be be refactored in future work.

Why are we defaulting to labels match over series?

For many reasons listed here:

First, when we made the type and version detection feature in the config section, many people did not have the most current versions of Prometheus and so were still needing to have the series endpoint be default. It is now a year and a half later and most people have update Prometheus versions that support the labels match endpoint.

Second, we are moving to refactor all series endpoint calls out of the Prometheus data source plugin and this is a part of that work.

Third, the series endpoint is expensive to call and we think that people should have to opt into that.

Special notes for your reviewer:

  1. Create a new Prometheus data source.
  2. In the config section, do not set the type and version.
  3. Go to the metric builder and open the metric select.
  4. Type a partial metric name and check the network tab to see that /api/v1/label/__name__/values?match[]=<series_selector> has been called.

Also, to see the series endpoint called, set the type and version in the config section to Prometheus type < 2.24 or follow the following guidelines for not supporting the label endpoint with match[] param

hasLabelsMatchAPISupport(): boolean {
return (
// https://github.com/prometheus/prometheus/releases/tag/v2.24.0
this._isDatasourceVersionGreaterOrEqualTo('2.24.0', PromApplication.Prometheus) ||
// All versions of Mimir support matchers for labels API
this._isDatasourceVersionGreaterOrEqualTo('2.0.0', PromApplication.Mimir) ||
// https://github.com/cortexproject/cortex/discussions/4542
this._isDatasourceVersionGreaterOrEqualTo('1.11.0', PromApplication.Cortex) ||
// https://github.com/thanos-io/thanos/pull/3566
//https://github.com/thanos-io/thanos/releases/tag/v0.18.0
this._isDatasourceVersionGreaterOrEqualTo('0.18.0', PromApplication.Thanos)
);
}

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.

Copy link
Contributor

@gtk-grafana gtk-grafana left a comment

Choose a reason for hiding this comment

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

😎

@bohandley
Copy link
Contributor Author

😎

😎 👍🏻

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.

Prometheus: Default to calling the /label/<name>/values endpoint instead of /series
4 participants