How can I make a Grafana template with a variable reference another variable using Prometheus as a datasource?

checketts picture checketts · Jan 20, 2017 · Viewed 36.8k times · Source

I have a Grafana dashboard with template variables for services and instances. When I select a service how can I make it filter the second template variable list based on the first?

Answer

checketts picture checketts · Jan 20, 2017

You can reference the first variable in the second variables query. I'm not certain if there is a way using the label_values helper though.

First variable
query: up
regex: /.*app="([^"]*).*/

Second variable:
query: up{app="$app"}
regex: /.*instance="([^"]*).*/

enter image description here