2
votes

This is probably simple and I am missing some piece.

I have a grafana dashboard backed by prometheus. Prometheus is running in two different kubernetes cluster.

What I want is the first dropdown to be the cluster - say A and B. And based on what I select in the first dropdown, I want the values populated in the second dropdown. The second dropdown in my case is label_values.

The first dropdown is defined by variable datasource and is type datasource and type for datasource options is prometheus.

For the second dropdown, I have variable service, type=Query.

In the query options, I define the query as label_values(rt) but that gives the values of all labels irrespective of the cluster I chose in the first dropdown.

Any help is appreciated.

1

1 Answers

2
votes

You need to use the value of the first template variable in the query for the second. I.e. assuming your metric labels for cluster and service are actually cluster and respectively service then you should define your template variable queries as:

cluster: label_values(up, cluster)
service: label_values(up{cluster="$cluster"}, service)

This will automagically populate the second dropdown whenever you change selection in the first.