I exported one of my dashboards into a JSON file via the dashboard API [^0]:
curl -s -H "Authorization: Bearer $api_key" -X GET "$domain/api/dashboards/uid/$uid" | jq > dashboard.json
But it’s weird that when I try to upload it manually via the UI the dashboard is totally blank.
Did I do something wrong?
[^0] Dashboard HTTP API | Grafana documentation
You exported it from what version of grafana and imported it to what version?
Dashboard “export” API is not the same as UI export from. Just try to export the same dashboard via UI and then via API and compare outputs. They are similar, but they are not the same => you can’t mix API/UI exports/imports (at least not without additional transformation), because they use different models.
Is there a good reason for this difference?
It would seem to me to be beneficial if either the two formats could be made to
be the same, or at least the one which requires less data could ignore the
additional data produced by the other. That way, at least one direction would
I’m intrigued as to why two different methods of achieving what appears (at
least to the average user) to be the same thing are incompatible.
API aproach is only GET dashboard (not “export” dashboard) = it will provide model, which is used by app itself (so you can see internal ids/uids there) - “internal” model = this model can be used only in that particular Grafana instance.
UI is a real dashboard export, which will transform internal model (e.g. replace internal ids/uids, remove sensitive details) so this output can be imported into another Grafana instance without any issue.
It will be nice to have API for dashboard export, but that API still doesn’t exist. Export feature is still implemented only in the UI - frontend.
BTW: @amotl made a feature for programatic dashboard export.