How to Call Prometheus DS into React Panel Already Using a DS

Hi,

I have developed a grafana backend data source and a panel plugin. Currently, I am fetching data from backed DS and display it on my panel.
Now, I want to combine results from Grafana’s Prometheus datasource and my personal datasource and display the results on my own panel.
Currently, I get the data from my personal backend datasource into the props in my react plugin. I don’t know how can I query the Prometheus datasource from the same panel? Can someone guide me how can I send the data request/query request? How will I get the response?
Your help/response on this will be very appreciated.

Hello @fouziakhan95,

I use the example way to get datasource in my plugin:

import { getDataSourceSrv, getBackendSrv } from '@grafana/runtime';
...
// this should be a name of your datasource selected in panel,
// or hand write it:
const dsName = this.data.request.targets[0].datasource;

getDataSourceSrv().loadDatasource(dsName).then(result => {
  // you got a datasource, not you can query it for data
}) 

Regards,
V.

1 Like