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

Populate metric selector for custom metrics #348

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

dgrisonnet
Copy link
Member

When querying custom-metrics, the metric label selectors weren't populated in the resulting values.

A query with a metricLabelSelector query parameter set to endpoint=https was resulting in the following MetricValueList:

{
  "kind": "MetricValueList",
  "apiVersion": "custom.metrics.k8s.io/v1beta1",
  ...
  "items": [
    {
      ...
      "selector": null
    }
    ...
}

With this change, it now appears as:

{
  "kind": "MetricValueList",
  "apiVersion": "custom.metrics.k8s.io/v1beta1",
  ...
  "items": [
    {
      ...
      "selector": {
        "matchLabels": {
          "endpoint": "https"
        }
      }
    }
    ...
}

/cc @s-urbaniak

When querying custom-metrics, the metric label selectors weren't
populated in the resulting values.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
}

func (p *prometheusProvider) metricsFor(valueSet pmodel.Vector, info provider.CustomMetricInfo, namespace string, names []string) (*custom_metrics.MetricValueList, error) {
func (p *prometheusProvider) metricsFor(valueSet pmodel.Vector, namespace string, names []string, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: I changed the order of the parameters here to match the metricFor function

@s-urbaniak
Copy link
Contributor

lgtm, thank you!

@s-urbaniak s-urbaniak merged commit f33fc94 into kubernetes-sigs:master Dec 15, 2020
@s-urbaniak
Copy link
Contributor

@dgrisonnet just because i simply forgot: as a follow-up we could potentially add some tests, wdyt?

@dgrisonnet dgrisonnet deleted the populate-selector branch December 15, 2020 15:21
@dgrisonnet
Copy link
Member Author

yes, that would definitely be a great addition. However, since I am not too familiar with prometheus-adapter test framework, it might take me some times.

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