Variables across multiple datasources

I am trying to create a dashboard where a single variable can pull values from multiple datasources. Right now, query variables can only use one datasource, which makes it difficult to:

  • Combine values from different datasources into one variable.

  • Filter panels across multiple datasources using a single variable.

  • Provide “Include All” behavior for combined results.

My setup includes multiple clusters, each with its own datasource, and I would like a variable (e.g., namespace) that aggregates values across them. Panels should still use the appropriate datasource based on cluster selection.

Practical case:

I currently have three variables: datasource, cluster, and namespace. I want to remove the datasource variable. I can convert cluster into a custom variable, but then the namespace variable would need to search across all data sources and query them based on the selected cluster value.

Grafana version: 12.1.1

Is there a supported method to achieve this, or a recommended workaround? If this is not currently possible, I would like to request this as a potential feature.

Thank you for your guidance.

how many datasources are we talking about and do you want it to be dynamic? As in any new datasources would be automatically included without having to do any manual changes?

Best approach would be to leverage SQL Expression.

you would have all of the datasources as datasource in the panel and use cluster variable as filter on all of them then with SQL Expression you would join them all for the final result.

The one thing to remember with SQL Expression is that it expects the data source to be backend enabled.