How can Panel plugin invoke the Datasource plugin to make a request when user clicks on panel's button? Can I add my callback from datasource for panel?

Hi, I have working datasource-plugin and panel plugins frot Grafana 7.X
In a panel plugin I want to have say a button “Make specific request”, and I want this request to be done from datasource. How can I invoke it from the panel? Can I add some custom callback to my panel or shoud it be done through some events subscription? Looks like location variables are not the option. Thanks
Is it legal?

/*From the Panel Plugin */
import { getDataSourceSrv } from '@grafana/runtime';
const myDatasource = getDataSourceSrv();
.then(dataSourceInstance => dataSourceInstance.makeSpecificRequest("specificParams"))

Hello. Did you get a solution to this? I’m new to Grafana and I’m looking for a similar functionality.
I have to make a request (GET/PUT/POST) from the panel but through the datasource plugin since that has the authentication.
Please let me know if there’s a way to do this.



Im also looking for this

Consider adding a resource handler to your data source. This essentially extends the Grafana REST API with a custom route for your data source that will be available to any panel.

Check out the post on How to add a resource handler for your data source for more information.

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