grafana批量导入、导出、删除模板的脚本

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

猜你喜欢

转载自blog.csdn.net/hzx1464138068/article/details/79391125
今日推荐