Refresh Datasource on variable change

Hi All,
i create a custom datasource and i’m using it for filling a Table (OOTB grafana table). For now it is working fine but i have to do an enhancement, the datasource should be filtered according to a variable so after the variable change the table should refresh with the new “filtered” content.
Unfortunately when i change the variable value there is no refresh (i should manually trigger a refresh).
How can i specify that my datasource could change response according a variable so if a variable change the data from datasource should be refresh?
Thank you so much.


In your OnChange you can put a onRunQuery()


Hi Nicolas,
as far as i know onchange is called only in configuration. Am i right?


Hmm, can you send me your query editor, im using a select so i have an onchange in this.


If you do replaceVariables inside the Data Source, it won’t trigger the update when the variable is refreshed.

The Query Editor for the Data Source variable should have a text input, which uses the variable, and then you can do replaceVariables from it.

My problem is no during the edit mode. When I have already configured a table with my custom datasource if user change the value of a variable i want to refresh the content of the table.

This is what I was saying, and it works for our data sources.

  1. Variable change will trigger Data source update.
  2. Data Source should use a Variable in the Input box to retrieve data.
  3. Data change in Data Source will trigger Table refresh.