Populate dashboard variable from 2 queries?

  • What Grafana version and what operating system are you using?
    Grafana Cloud with Prometheus and Infinity data sources

  • What are you trying to achieve?
    Is there a way to have a dashboard query variable that’s populated by the combination of 2 queries?

  • How are you trying to achieve it?
    These metrics are all labeled with their hostname in the instance label. I use 2 dashboard query variables for site and instance. The first is a query to Netbox (using Infinity GraphQL) to get a list of sites. The second is another Netbox query getting a list of hostnames in the chosen site. This works great as a general pattern.
    But I have a few instances which are not yet documented in Netbox, and I’d like to see those on the same dashboard too, with unknown site. So I add another variable that queries a list of instance labels from the node_exporter_build_info metric.
    Now I’m looking for a way to join these 2 query variables into one big list.

You can define joined variable like in the example below, but it will be populated with all values only when all values of var1 and var2 are selected:

1 Like

Thanks, that’s a clever idea. That does work but it’s pretty clunky to use. I don’t really know how else it could work though… maybe it’s best to make 2 separate dashboards for this.

Look at the new SQL expression datasource that you can use to marry two disparate data sources