Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Command to export all grafana 2 dashboard to JSON using curl
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KEY=$(<~/.grafanakey)
HOST="https://mdmdev.cloudtrust.rocks"
if [ ! -d $SCRIPT_DIR/dashboards ] ; then
mkdir -p $SCRIPT_DIR/dashboards
fi
for dash in $(curl -k -H "Authorization: Bearer $KEY" $HOST/api/search\?query\=\& | jq -r '.[] | .uri'); do
curl -k -H "Authorization: Bearer $KEY" $HOST/api/dashboards/$dash | sed 's/"id":[0-9]\+,/"id":null,/' | sed 's/\(.*\)}/\1,"overwrite": true}/' | jq . > dashboards/$(echo ${dash} |cut -d\" -f 4 |cut -d\/ -f2).json
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.