Reputation: 14963
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?
Upvotes: 18
Views: 44968
Reputation: 21
****Variable 1 (get labels from metrics, ends with below):**
name: instance
label: instance
type: Query
Query: label_values({name=~".*jvm_JvmMetrics_MemNonHeapUsedM"}, instance)
****Variable 2 (depends on variable 1)**:
name: task_name
label: task_name
type: Query
Query: label_values({name=~".*jvm_JvmMetrics_MemNonHeapUsedM",instance=~"$instance"},task_name)
Symbol "~" for multiple values
Upvotes: -1
Reputation: 882
label_values works just fine using variables. For ex:
label_values(cassandra_keyspace_readlatency_count{product="$product"}, keyspace)
Upvotes: 8
Reputation: 14963
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="([^"]*).*/
Upvotes: 24