Dashboard query variable - filter the list using another variable

What Grafana version and what operating system are you using?

Grafana 9.3.1 on Debian 11

What are you trying to achieve?

I have a dashboard with 3 variables:

  • datasource (a centralised prometheus server)
  • boxname: label that is applied to all metrics that are scraped from a given target server
  • services: label that is applied to each distinct scraped target inside a given target server

=> 2 distincts target servers shares some of the service labels but have also specific ones.

After selecting a box name, the services dropdown should only display values for services that are effectively present on this server.

How are you trying to achieve it?

I have:

Variable Definition
datasource prometheus
boxname label_values(boxname)
service label_values(service)

But the service variable does not depend on boxname and so all services for all servers are shown in the drop down.

How can i restrict the list ?

Did you follow any online instructions? If so, what is the URL?

I tried to carefully dig the doc e.g: Prometheus template variables | Grafana documentation
and the forum without success, but might have missed something because it seems to be quite a classic requirements

Among others, I could not find the syntax to use the query_filter(query) for prometheus DS that sounds promising.