Skip to content

Instantly share code, notes, and snippets.

@flisky
Forked from crisidev/grafana-dashboard-exporter
Last active October 6, 2021 18:57
Show Gist options
  • Save flisky/b5c0a63bc1557322f62a81406ce4cac1 to your computer and use it in GitHub Desktop.
Save flisky/b5c0a63bc1557322f62a81406ce4cac1 to your computer and use it in GitHub Desktop.
Command to export all grafana 3 dashboard to JSON using curl & jq
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
@sellers
Copy link

sellers commented Dec 2, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment