simPod/GrafanaJsonDatasource

Fetch multiple panels via one request

MatinF opened this issue · 7 comments

We have a use case where we wish to use the JSON plugin to fetch data from our backend.

In our setup, we need to have multiple individual panels in Grafana, each of which will involve different time series parameters. We wish to be able to send 1 request for all the panels together to our backend for processing. The reason is that our data is structured in 'log files' and opening & processing a log file takes a lot of time. If we e.g. have 5 panels, this would result in 5 x the time spent compared to if we can fetch the 5 panels as 1 request to our backend.

Is there a way of achieving this today with the JSON plugin?

I know Grafana has a feature to read data of one panel from another panel. But this is irrelevant to this datasource, it's Grafana related.

Hi again,

Thank you for the swift response. I do realize that there is an option in Grafana to share queries as per below:
https://grafana.com/blog/2020/10/14/learn-grafana-share-query-results-between-panels-to-reduce-load-time/

The challenge with that approach is that it requires creating a 'pseudo master panel' to trigger all queries for use in other panels. It would be more user-friendly to enable the creation of individual unlinked panels - and then have the plugin "collect" the panel queries before then parsing a "joint query request".

Is this something that is possible to implement on the plugin side, or does the Grafana integration prohibit this?

No AFAIK. There's strict API DataSource should follow so there's no control over query batching.

export class DataSource extends DataSourceApi<GrafanaQuery, GenericOptions> {

I tried using the built-in query sharing in Grafana, but it seems it will not be possible to achieve my use case with this. I've outlined the problem here: https://community.grafana.com/t/how-to-reference-a-single-query-from-another-panel-not-all/62046

In short, the Grafana query sharing only seems to work for use cases where Panel X needs to be a 1:1 copy of Panel Y. But we would instead like to bundle all our queries by creating a "Query Panel" that e.g. sends out 10 queries - and then reference each of these queries in individual panels. However, the individual panels seem to only be able to reference the results of all the 10 queries together, which makes this method not suitable.

If you have any other suggestions, I would be very interested.

Did you try returning 10 Dataframes and then filtering single one using transformations?

Thanks for the tip. I did look into transformations and I think it could be the solution I would need. However, currently with SimpleJSON that I've been using I am unable to get it working - seemingly because the SimpleJSON response does not include the required refId: grafana/grafana#46385

grafana/simple-json-datasource#164

I'm not sure if your JSON plugin responses include this - and if you've had the chance to test if filtering by query works with your plugin?

I guess it's because it's outdated. Use this plugin.