Dashboard API - Returns query results as well?

This is probably obvious, but the documentation is not extremely clear and my testing is inconclusive:

Is GET /api/dashboards/uid/:uid supposed to return both the dashboard meta/model & resulting data from the panel queries, or just the dashboard meta/model?

Just the dashboard and meta models. The dashboard model contains an array of panels and each panel has a targets property which contains the panel query (or queries):

      "targets": [
        {
          "refId": "A",
          "target": "scale(apps.backend.backend_03.counters.requests.count, 0.3)"
        }
      ],

When the dashboard is refreshed, Grafana loops through all the queries and calls the appropriate data source with the query from the panel.

Thanks!

I am trying to generate a snapshot of the dashboard through the API (api/snapshots), but it is not clear to me how to programmatically get the panel data to post to the snapshot API. That is why I was trying to query the dashboard.

What am I missing?

Unfortunately, this is currently hard to do:

I’ll see if I can find a better way to do this with the current API.

Thanks, that was the conclusion I was coming to.

@daniellee This is hacky, but it works for my use-case - it just simulates clicking on the generate snapshot link. Using Apify’s synchronous API, the API call will return the snapshot URL.

https://www.apify.com/defensivedepth/grafana-generate-snapshots

1 Like

daniellee:

Is there a means to return just the data (results) in a json format vs all the data for the panel?

Not really. Grafana takes the dashboard json, parses out the queries for each panel and executes them.

So you could do the same thing but that would be quite a lot of code (template variables, different data sources, series overrides, timeshift overrides etc., ) - basically the whole dashboard rendering javascript from Grafana.

@daniellee Has there been any further movement on this issue? RE: creating a snapshot via the API.

Thanks!