kubernetes-sigs / prometheus-adapter

An implementation of the custom.metrics.k8s.io API using Prometheus
Apache License 2.0
1.9k stars 551 forks source link

Accessing metric labels in name.as #578

Closed sam701 closed 1 year ago

sam701 commented 1 year ago

I have a few prometheus metrics queue_length{queue_name="xyz"} that I want to map to external metrics. I would like to be able to do something like this:

- seriesQuery: queue_length
  mericsQuery: max(queue_length) by (queue_name)
  name:
    matches: ""
    as: '<<index .LabelValuesByName "queue_name">>_queue_length'

but unfortunately the as part does not support templates and the resulting metric name contains <<index....

In order to fix this I have to change the original prometheus metric name to be xyz_queue_length. The downside is:

It would be great to have support for templates in the name.as part or some other mean to access metric labels.

k8s-ci-robot commented 1 year ago

This issue is currently awaiting triage.

If prometheus-adapter contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
sam701 commented 1 year ago

Sorry, I overlooked the fact that the labels are copied into the k8s metrics and can be user in the HPA/selector. It is not an issue any more. Closing...