I want the name of the datasource

I have a Dashboard in Grafana with a Prometheus data source variable named $privatePromDataSource, which corresponds to three Prometheus data sources—AA, BB, and CC. The variable is used to dynamically switch between these data sources in the Dashboard.

Now, I want to define a second variable called $system_name, which is a Query type. The intention is to query MySQL with the statement select distinct system_name from kc_grafana_nginx_info where state=1 and data_source = $privatePromDataSource. The goal is to dynamically obtain system_name based on the selected Prometheus data source.

However, it seems that the filtering with data_source = $privatePromDataSource is not taking effect, and I’m getting results for all system_name values instead of those specific to the chosen Prometheus data source.

Is there a way to achieve dynamic parameter passing from the selected Prometheus data source to a MySQL query variable in Grafana?