Populating multiple panels from a single query

In a dashboard, I’ve two panels. Of these two panels, I am only using one of the them to send query to my datasource. (which is simple JSON datasource).

I am getting two lists of data points as a response from my JSON data source. I wanted to display individual graph for these two list. Is there a way in grafana to direct your response to different panels.

Let’s suppose, the response I got is -

[
  {
    "target": "Interface A ",
    "datapoints": [
      [
        24940000,
        1493288180000
      ],
      [
        22604000,
        1493288200000
      ]
    ]
  },
  {
    "target": "Interface B",
    "datapoints": [
      [
        38836000,
        1493288180000
      ],
      [
        45792000,
        1493288200000
      ]
    ]
  }
]

For target name “Interface A”, and “Interface B”, I want to show two different graphs in two individual panels within a same dashboard.

One way of doing this would be, in response if we could explicitly tell the panel ID to which this response should go

Is the query really expensive? Why not just send the same query from both panels and use Interface A from the result for panel 1 and Interface B for panel 2?

Yup, the query is really expensive. Initially, I had thought of the same way to do it but later realized the data returned by query is quite large.
Hence, querying my data source twice isn’t going to be the efficient option.

But it sounds like you have control over the data source? Can you not send in a parameter and return half the data depending on whether it is for Interface A or for Interface B?

Actually, the data source is kinda acting as a middleware which in turn is talking to a database service through its APIs. So handling and parsing the data in middleware wouldn’t be feasible as it will affect other normal queries.

I mean this work around can work, but I was looking for solution in grafana if it has any feature where we can redirect the response to different panels.

Also to give more clarification - it’s a single query. For example, the query looks like this -

Select target, dataPoints from table "A" group by target

The query returns data points group by interfaces A and B. It can respond with data points for multiple interfaces depending on the table we are querying.

I am sending the query through a single panel and wants the output to be distributed across multiple panels depending upon the number of interfaces the query has returned. Thus, sending parameter to return half data would not provide the solution as this approach does not look scalable.

Hello,
I have the same need : A big query which fetch multiple metrics.

I want to avoid executing multiple time the same query to populate several panel.

Any idea?

Thanks