Skip to content

Instantly share code, notes, and snippets.

@h3po
Created July 20, 2018 11:04
Show Gist options
  • Save h3po/7207bfe0d476bff383ab11253a2c486c to your computer and use it in GitHub Desktop.
Save h3po/7207bfe0d476bff383ab11253a2c486c to your computer and use it in GitHub Desktop.
Quick script to export all grafana (5.0) dashboards as json
import requests
import json
headers = {
"Authorization": "Bearer <insert an admin token here>"
}
endpoint = "https://<grafanahostname>/api"
dashboards = requests.get(endpoint + "/search", headers=headers, verify=False).json()
for dashboard in dashboards:
data = requests.get(endpoint + "/dashboards/uid/" + dashboard["uid"], headers=headers, verify=False).json()
with open(data["meta"]["slug"] + ".json", "w") as f:
f.write(json.dumps(data["dashboard"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment