Prometheus template variable in another template?

$cluster	| label_values(elasticsearch_indices_docs,cluster)
$instance	| label_values(elasticsearch_indices_docs,exported_name)

Is it possible to have the possibilities given by $instance change when I change $cluster ?
(Each cluster has different unique instances.)

more: I have a bunch of metrics that are based on $instance like elasticsearch_jvm_memory_used_bytes{exported_name=~"$instance"} I’d like to have only the metrics of the instances of the cluster when I select a cluster.

1 Like

of course, if you use another variable in your template variable query they become linked so if you update one all the variables that use it will also update.

Cool !
But I could not find any example or tutorial showing it, do you have one ?
thanks !


label_values(metric{label=~"$othervariable"}, otherlabel)

Great thanks ! Worked with label_values(elasticsearch_indices_docs{cluster=~"$cluster"}, exported_name)

1 Like

Not work for me here. I have two variables: cluster and instance, when select cluster1, instance shown None instead of all instances in cluster1. Dont know why, any suggestions?


and here is my metric model in prometheus:

for more infos here:
how to assign one variable to another while using grafana templating #14389