Refresh button on Grafana datasource backend plugin

Hi there!

Im developing a datasource backend plugin for calling some data from a postgresql database. Im able to connect to the database and make queries when pressing on a button in my query editor by using this.props.onRunQuery();

However, Im not able to make queries when pressing on the “Refresh dashboard” button (top right). So the data I get when creating the panel is static.
Captura de pantalla 2021-06-11 120404
How can I make a query when pressing that button? Any help? Why the refresh dashboard button dosen’t make any more queries?

The query method on your DataSourceApi class is executed every time the user requests new data (by for example clicking the Refresh button). Try adding a log statement at the start of your query method. It should log every time you press refresh.

2 Likes

Thanks for your help! I really apreciate it :smiley:
Yeah you are right, the query method it is executed every time the user requests new data.

The problem is that the panel doesn`t update its content every time the queries are done.

I found the problem:
I construct the SQL query when pushing a button in the QueryEditor so the query doesn’t change when pressing the “Refresh dashboard” button.

I think what I should do is create the SQL query in the function query inside datasource.ts file.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.