grafana导入导出模板的脚本:
#!/bin/bash
curl -s http://源ip:3000/api/search|jq '.[].uri'|tr -d '"'|while read line
do
A=`curl -s http://源IP:3000/api/dashboards/${line}`
B=`echo $A|sed 's@"hideControls":false,"id":[0-9]*@"hideControls":false,"id":null@g'`
echo $B
curl -H 'Content-Type:application/json' -d "$B" "http://目标IP:3000/api/dashboards/db"
done
grafana删除全部模板的脚本:
#!/bin/bash
curl -s http://源IP:3000/api/search|jq '.[].uri'|tr -d '"'|while read url
do
title="http://源IP:3000/api/dashboards/"$url
echo $title
curl -X DELETE -H 'Content-Type:application/json' "$title"
done