JSON API, one endpoint query for multiple panels

  • What Grafana version and what operating system are you using?

v10.0.3

  • What are you trying to achieve?

Using the JSON API plugin, I have an endpoint that returns all data need for a dashboard, similar to:

{
  "key1": [
    { "objectData" },
    { "objectData" },
    { "objectData" },
  ],
  "key2": [
    { "objectData" },
    { "objectData" },
    { "objectData" },
  ],
  "key3": [
    { "objectData" },
    { "objectData" },
    { "objectData" },
  ]
}

I would like to call that endpoint in one panel, and extract just the key for that particular panel, rather than repeating the api call for each panel as it’s an expensive call.

  • How are you trying to achieve it?

I’m trying to use some combinations of transforms to get what I need but haven’t exactly figured it out. I can use “extract fields” if I know exactly how many items are in the array that’s returned, but that’s not really feasible when I don’t know the length. I feel like this is possible but I haven’t been able to get it to work.

I appreciate any nudges in the right direction!

Welcome to the Grafana forum.

Would that be this JSON API plugin or this JSON API plugin?

If you have not already checked it out, the Infinity plugin has JSON query ability and a lot of options to go deeper and be more selective.

Hi @rchamberlin. Did you manage to solve the problem? I am also facing the same problem. Now I call the same API n times and filter in UQL Query with ‘parse-json
| jsonata “data.x”’ in panel 1, with ‘parse-json
| jsonata “data.y”’ in panel 2 and so on, but it is very expensive to call the same query n times and if someone manages to call it only once, it can be saved somewhere and then used in the panels (plugin used: Infinity)?

Welcome @andy95

Please post a sample of your data

Hi @andy95 I was not able to solve the problem. @grant2 mentioned trying the Infinity plugin like you have, but I still had to call the api for each panel that uses the data as far as I can tell.

maybe this could work @rchamberlin

hi @yosiasz. I have a URL query that I call in each panel and from there I choose my axis (x,y,z). I would like to call that query only once and then in each panel to take only what I need (depending on the axis)
sample data:

 [
    {
        "someProperty1": "",
        "someProperty2": "",
        "keylvl1": {
            "keylvl2": {
                "keylvl3": {
                    "x": [
                        {
                            "obj1": 26,
                            "obj2": 0.02,
                            "obj3": 1187,
                            "obj4": 0.038,
                            "obj5": 47.52
                        },  
                        {
                            "obj1": 42,
                            "obj2": 0.05,
                            "obj3": 1612,
                            "obj4": 0.052,
                            "obj5": 52.42
                        }      
                    ]
                 //same for y and z
                },
            },
        }
    }
]

UQL Query:
Panel 1
parse-json
| jsonata “keylvl1.keylvl2.keylvl3.x”

Panel 2
parse-json
| jsonata “keylvl1.keylvl2.keylvl3.y”

Panel 3
parse-json
| jsonata “keylvl1.keylvl2.keylvl3.z”

anyone some idea?