In Grafana v9.3.4
I have the following 2 template variables named instance
and mssql_instance
.
The first one returns the instance (e.g. "winserver") and the second one return the SQL instances of the instance "winserver" (e.g. "mssqlserver", "dev"). Both of them are coming from Prometheus.
I have another template variable named sql_datasource
which returns all the SQL data sources of Grafana (e.g. "winserver_mssqlserver", "winserver_dev", "winserver2_mssqlserver", "winserver2_server2").
In my dashboard I have mixed panels, few of them project metrics from Prometheus and the rest of them project TSQL Queries.
I have implement the Prometheus variables in the Prometheus panels like this:
mssql_user_connections_per_database{instance=~"${instance}:.+",mssql_instance=~"$mssql_instance"}
So when I change the template variables (instance
& mssql_instance
) all the panel variables are changing accordingly.
I have also implement the SQL data source variable in the SQL panels but this time I have put the variable in the data source field like the following: ${sql_datasource}
.
As an addition I have implement a 4th template variable named sql_datasource_auto
that combines the 2 variables instance
and mssql_instance
in order its output to be the same as the sql_datasource
. And it looks like the following:
SELECT CONCAT('${instance}', '_', '${mssql_instance}') AS sql_datasource_auto
If I choose instance
= winserver and mssql_instance
= dev, then the sql_datasource_auto
variable will be winserver_dev.
And here comes my question.
Is there any way that, the sql_datasource
can always have the same value with sql_datasource_auto
?
I tried to find a way in order to combine the values but I didn't succeed.
I don't know if what I am asking is possible because the variables are coming from 2 different data sources.