How to export and import a Grafana dashboard

Like many things, it is easy once you know how. The instructions on the internet usually missed one tiny critical piece of information. |←

Export a dashboard

In Grafana, select a dashboard. At the bottom of the display select |← (circled in the image). (This was the missing bit of information.)

  • This gives you icons
    • Download
    • Content outline
    • ->|
  • Select Download. This gives

You can either Download the file, or copy to the clip board. Because Grafana is running in a browser, the downloaded file is in your normal Downloads directory. One download had a name dashboard-1791876486315.json

Importing a dashboard

In Grafana, select Dashboards

Select the +^ on the top line, and select import dashboard.

You can drag and drop a file to the area, or select from a file list.

How do I save Grafana dash boards?

There is documentation on the internet explaining how to save (share) dashboards. It goes like “from the hamburger icon select share dashboard”. I do not have the hamburger icon. I think this is because I am using the free opensource version.

I found a pointer to a script on the internet

#!/bin/bash

x=$(curl -u admin:password http://localhost:3000/api/search?query= )

for uid in $(curl -u admin:password http://localhost:3000/api/search?query= | jq --raw-output '.[].uid') ; do
echo $uid
curl -u admin:panthe0n "http://localhost:3000/api/dashboards/uid/$uid" > "dashboards/$uid.json"
done

The output was a JSON file. I do not think you can import it back into Grafana (because it says it does not have a matching schema), but at least you can see what the contents were, and manually add them back into Grafana.

There is a more modern API such as

curl -u admin:panthe0n  http://localhost:3000/apis/dashboard.grafana.app/v1/namespaces/default/dashboards?limit=10

which will list all dashboards and their contents.

The modern API allows you to create dashboards – but I’ll leave this till another day.