-
-
Save flisky/b5c0a63bc1557322f62a81406ce4cac1 to your computer and use it in GitHub Desktop.
Command to export all grafana 3 dashboard to JSON using curl & jq
This file contains 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
KEY=XXXXXXXXXXXX | |
HOST="https://metrics.crisidev.org" | |
mkdir -p dashboards && for dash in $(curl -k -H "Authorization: Bearer $KEY" $HOST/api/search | jq -r '.[].uri|ltrimstr("db/")'); do | |
curl -k -H "Authorization: Bearer $KEY" $HOST/api/dashboards/db/$dash | jq '.dashboard' > dashboards/$dash.json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should be able to get the data by directly crafting the URL for a given graph too, such as
curl http://graphite.site.org/render?target=aliasSub(groupByNode(offset(scale(perSecond(env1.hostgroup1.host01.platform.cpu-*.cpu-idle),-1),100),2,'max'),'^.*(\D+)(\d2)(.*)$','\2')&from=-604800seconds&format=json
This should return a JSON blob of data. The above shows the CPU usage as an inverse (-1) of the CPU idle metric reported by the collector. This is basically the URI information pulled form the edit screen of a given graph in a given Dashboard instead of the entire dashboard data. Let me know if this is helpful or off base from the desired.