Created
November 3, 2017 11:02
-
-
Save devcfgc/c8e67af7f1c2389c230ac860da6a1a90 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
FYI I had to alter
cut -d "," -f 3
and change the "3" into "4" to get the uri's to the db-files.