How to make a Grafana template with a variable reference another variable using Prometheus as a data source?

I have a Grafana toolbar with template variables for servicesand instances. When I select a service, how can I get it to filter the second list of template variables based on the first?

+5
source share
4 answers

You can reference the first variable in the second variable query. I'm not sure there is a way to use the helper label_values.

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

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

enter image description here

+11
source

InfluxDB , :

SHOW TAG VALUES WITH KEY = "cpu" WHERE service =~ /$service/

$service - .

+2

label_values , . :

label_values(cassandra_keyspace_readlatency_count{product="$product"}, keyspace)

enter image description here

0

1 ( , ): : : : Query Query: label_values ({ name= ~ ". * Jvm_JvmMetrics_MemNonHeapUsedM"}, )

2 ( 1): : _ : _ : label_values ({ name= ~ ". * Jvm_JvmMetrics_MemNonHeapUsedM", instance = ~ "$ instance"}, _)

"~"

0

Source: https://habr.com/ru/post/1667400/


All Articles