How to query datasource plugin from panel plugin

Hi,

I have built a grafana datasource plugin similar to simple-json-backend-datasource plugin example and the data is getting fetched into the Grafana builtin table panel. Now I want to query this datasource in order to get data inside my own panel plugin which I have to build yet. But I don’t know how can I query the data from my panel plugin. I tried looking for some sort of documentation on it but couldn’t find any. Also I checked the ‘Query (options)’ function from frontend script of backend-datasource plugin, however, seems like the options parameter is quite long and I am not sure how to create it. It will be good to know which fields are mandatory and which aren’t. Is there some documentation one could refer to me or explain how the request needs to be made to the DS?

P.S: Though there is a small part on request format under simple-json-backend-datasource documentation but I’m unable to understand how the request should be generated from panel plugin and which fields are mandatory for a table response and which are optional.

3 Likes

In case someone else is looking for the answer too:
Apparently, the datasource can be added from the panel. The query to datasource is made automatically as the panel loads. In custom panel typescript, I can get the datasource response in props. In my case it was as simple as this.

Hi,

I would still like to have a response on this.
I have a self made grafana backend data source and a panel plugin. Currentlly, I am fetching data from backend and showing on my panel plugin.
Now, I want to combine results from grafana existing datasource and my personal datasource and display them on my panel plugin.
I’m using typescripts for panel plugin. I get the data from my personal backend datasource into the props in react plugin. But how can I query the grafana datasource (e.g. Prometheus datasource) from the same panel? How can I send the data request/query request from my frontend? How will I get the response?
Your response will be really appreciated.

2 Likes