GET api chaining

Hello
We are using JSON API datasource to collect cluster details including cluster ids using api query (/rosa/clusters).
Now I need to use the output of the each cluster ids {filed name is id} to get the node details of each with other query GET request (/rosa/{id}/nodes).
Is there a way to display it in another panel by passing the value of cluster id {id} /rosa/{id}/nodes to get the details?

Yes this is possible to do. What dashboard are you using for this to display the end result?

Would using a dashboard variable work? i.e., the results of the first GET query sets a dashboard variable foo, and another panel references that variable in its query as $foo ?

1 Like

Grafana Dashbaord.
Fyi I am able to list the ids now for each clusters to get count of nodes from each cluster ids.Is it possible to show the over all count of those ids.
Ex : Lets say I have 5 clusters with 3 nodes each . I need to show 15 as total in dashbaord as count rather than each cluster wise.

I’m facing a similar situation where I’m using a JSON API datasource to collect cluster details, specifically the cluster IDs, using the “/rosa/clusters” API query. Now, I need to utilize the output of each cluster ID (stored in the “id” field) to fetch node details for each cluster with another GET request using “/rosa/{id}/nodes”. My challenge is finding a way to display this node information in another panel by dynamically passing the cluster ID value “{id}” to the “/rosa/{id}/nodes” query to fetch the relevant details. Regards

what will be the final dashboard (time series, bar chart, timeline?) you will be using to display the data in?

Maybe you can use the static data source plugin to do the following js calls to the api to find clusters, loop through the clusterids then fetch the nodes

async function getClusters() {
  const response = await fetch("http://localhost:5000/rosa/clusters");
  let clusters = response.json();
  return clusters;
}

async function getNodes() {
  let nodes;
  for (let i = 0; i < data.length; i++) {
    let clusterid = data[i].clusterid;
    const response = await fetch(`http://localhost:5000/${clusterid}/nodes`);
    let node = response.json();
    
    nodes.push(node)
  }
  return nodes;
}

let data = getClusters();
let bonbon = getNodes();

console.log('bonbon', bonbon)
return Promise.resolve(data);