Forked from crisidev/grafana-dashboard-exporter
Last active
February 11, 2022 11:22
Star
You must be signed in to star a gist
Command to export all grafana 2 dashboard to JSON using curl
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
#!/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