Last active
July 7, 2020 12:27
-
-
Save ofen/a01b6b119bfc83d07d74ebf7a2b7f55c to your computer and use it in GitHub Desktop.
Export Grafana dashboards via API
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
#!/usr/bin/env bash | |
HOST="http://grafana.local:3000" | |
mkdir dashboards && \ | |
for dashboard in $(wget -qO- "$HOST/api/search?query=&" | jq -r .[].uri); do | |
wget -qO- "$HOST/api/dashboards/$dashboard" | jq -r '.dashboard | del(.uid)' > dashboards/"$(basename "$dashboard")".json | |
done |
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
#!/usr/bin/env bash | |
TOKEN=abc123 | |
HOST="http://grafana.local:3000" | |
mkdir dashboards && \ | |
for dashboard in $(wget --header="Authorization: Bearer $TOKEN" -qO- "$HOST/api/search?query=&" | jq -r .[].uri); do | |
wget --header="Authorization: Bearer $TOKEN" -qO- "$HOST/api/dashboards/$dashboard" | jq -r '.dashboard | del(.uid)' > dashboards/"$(basename "$dashboard")".json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment