1

I'm using Grafana to show Prometheus metrics. I have two variables in grafana, one is querying a label_values(kubernetes_name).

I want to create another variable which will provide instance label values, but I do not want to get all the values of this instance label, I want only those which came from a metrics that has kubernetes_name=$kubernetes_name where $kubernetes_name is coming from the first variable.

Basically, I want to be able to run this label_values:

label_values(instance)

only if those came from a metrics which had label

kubernetes_name = $kubernetes_name

I'm not even sure I can do values dependency like this, I couldn't find it in the docs :/

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
toto
  • 1,197
  • 2
  • 15
  • 26

1 Answers1

3

In the first variable use the following query:

label_values(kubernetes_name)

In the second variable use the following query:

label_values({kubernetes_name="$kubernetes_name"}, instance)
  • Nice... is there any documentation about this? I'm searching for a good place to read more about those options ;) – toto Jul 31 '20 at 12:35
  • 1
    I didn't find exactly this in the documentation, the closer I found is here: https://grafana.com/docs/grafana/latest/features/datasources/prometheus/#query-variable – Marcelo Ávila de Oliveira Jul 31 '20 at 12:56