Slowly climbing the learning curve.
Just lost “heureka”-solution in a dashboard - by accidentialy hitting a browser button
Desperate for a simple backup solution - one that I can understand as a Grafana newbie.
“Wizzy” seems not maintained any more, documentation and examples point to nirwana.
There was a simple skript out there
which looked liked it might fulfil my purpose.
After tearing my hair off, I found that it was broken due to a “Verschlimmbesserung” (sorry, english ‘disimprovement’ lacks the ironic subtility)
Grafana v5.0 is going to be the biggest and most foundational release Grafana has ever had, coming with a ton of UX improvements, a new dashboard grid engine, dashboard folders, user teams and permissions. Checkout out this video preview of Grafana v5 and the What’s New section in the docs for an overview of new features.
What’s new in Grafana v5.0
Checkout out this video preview of Grafana v5.
Download
New Major Features
Dashboards Dashboard folders, #1611
Teams User groups (teams) imple…
Old api url are deprecated.
Replacing uri
by uid
breaks readable directory.
Fixing both together breaks simplicity of the bash loop.
Anybody out who repaired this already? Or similiar?
a crude “works for the moment” solution:
rewrite the downloader to use uri
urls
save under the cryptic uri (keeping the simple bash loop)
add a ‘map’ file by a simple grep, so in desperation for a backup, one can manually lookup the uri pertaining to a dashboard name
tar-zip the whole to a time stamped archive, so the script can be called repeatedly without much thinking to prouduce skd of poor-man’s versioning
$ cat grafana-dashboard-exporter.sh
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# KEY=$(<~/.grafanakey)
KEY=$(< ./.grafanakey)
# HOST="https://mdmdev.cloudtrust.rocks"
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\=\& | 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
for dash in $(curl -k -H "Authorization: Bearer $KEY" $HOST/api/search\?query\=\& | jq -r '.[] | .uid' ); do
# dash=`echo ${json} | jq -r '.[] | .uri'`
# uid=`echo ${json} | jq -r '.[] | .uid'`
# echo ${json}
URL=$HOST/api/dashboards/uid/$dash
echo $URL
curl -k -H "Authorization: Bearer $KEY" $URL | 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
grep '"slug": ' dashboards/*.json > dashboards/map
DT_NOW=`date +"%F_%H%M%S"`
TGZ=dashboards_${DT_NOW}.tgz
echo $TGZ
tar -cvzf $TGZ dashboards/
Thanks for the hints.
Considered those, but
db backup does not allow dedicated restore of selected items (e.g. dahboard, panel or query). JSON is at least “a little bit” human readable.
as far as I understand, the YAML apporach breaks interactive UI development, so I think it is more apt to Grafana pros who know what they do.
Maybe i’m wrong, of course.
1 Like