Having 1 dashboard for several environments using Datasource variables with Grafana

I’m trying to add a datasource variable for InfluxDB in Grafana.

The idea is that I have duplicated dashboard for Local, Dev and prod environments. The dashboard is the same, the only difference is the connexion.

So I created a Datasource variable, now I can see in my dashboard, there is a combobox with all my connexions. But when I change it, my dashboard remains the same, all existing queries doesn’t change his own datasource.

Should I insert this variable into queries ? My original query is :

SELECT *  FROM "raw" WHERE $timeFilter 

I tried to do:

SELECT *  FROM $datasource..raw WHERE $timeFilter 

but I can’t make it work. What am I missing ?

What am I missing.

Don’t modify query. You need to select that datasource variable in your query editor:

1 Like

Amazing ! Thanks for the advice !