Get request object from metrics in dashboard

Hey! Our team develops panel plugin which takes all metrics from dashboard and sends them to backend. Backend takes those metrics, changes and queries them using Grafana as proxy.
It would be great to have access to raw queries from metrics of any panel in dashboard.
But, as I can see, right now plugins have access only to raw queries of InfluxDB datasource. And only after toggling edit mode.
It would be even better if panel had access to request object like I can see in query inspector. I wonder if there is a way to get it? Or should I generate it by myself for each type of datasource separately?

In the attached screenshot: yellow is the info about target I can get from my plugin and request field above is what I want to be able to get.

Thanks in advance for your answers!

Finally, I found a quite simple solution.

Everything you need to do is listen to ds-request-response event, which is emitted each time panel / dashboard refreshes. Then just call .refresh() on panel you need to get query from.

For example:

...
this.refresh();
appEvents.on('ds-request-response', data => console.log(data));

Result should look like this:

1 Like