Created
July 20, 2018 11:04
-
-
Save h3po/7207bfe0d476bff383ab11253a2c486c to your computer and use it in GitHub Desktop.
Quick script to export all grafana (5.0) dashboards as json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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