-
-
Save adivinho/0a5b7d04f7afef1c9107568547e67b66 to your computer and use it in GitHub Desktop.
backup grafana dashboard templates
This file contains hidden or 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=<api_token_key> | |
HOST="http://localhost:3000" | |
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\=\& |sed 's/{"id"/\\\n{"id"/g' |cut -d "," -f 3 | grep db |cut -d\" -f 4 |cut -d\/ -f2); do | |
curl -k -H "Authorization: Bearer $KEY" $HOST/api/dashboards/db/$dash | sed 's/"id":[0-9]\+,/"id":null,/' | sed 's/\(.*\)}/\1,"overwrite": true}/' > $SCRIPT_DIR/dashboards/$dash.json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment