toto
toto

Reputation: 1377

Use grafana variable dependency from other variable selection (with prometheus)

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 :/

Upvotes: 1

Views: 4169

Answers (1)

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)

Upvotes: 3

Related Questions