Skip to content

Instantly share code, notes, and snippets.

@ofen
Last active July 7, 2020 12:27
Show Gist options
  • Save ofen/a01b6b119bfc83d07d74ebf7a2b7f55c to your computer and use it in GitHub Desktop.
Save ofen/a01b6b119bfc83d07d74ebf7a2b7f55c to your computer and use it in GitHub Desktop.
Export Grafana dashboards via API
#!/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
#!/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