2018-07-16 03:53:41 -05:00
|
|
|
#!/bin/bash
|
2018-05-29 07:00:46 -05:00
|
|
|
|
|
|
|
bulkDashboard() {
|
|
|
|
|
2018-06-21 09:18:46 -05:00
|
|
|
requiresJsonnet
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-06-21 09:18:46 -05:00
|
|
|
COUNTER=0
|
|
|
|
MAX=400
|
|
|
|
while [ $COUNTER -lt $MAX ]; do
|
2018-08-20 12:21:32 -05:00
|
|
|
jsonnet -o "bulk-dashboards/dashboard${COUNTER}.json" -e "local bulkDash = import 'bulk-dashboards/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }"
|
2018-06-21 09:18:46 -05:00
|
|
|
let COUNTER=COUNTER+1
|
|
|
|
done
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-09-25 07:02:55 -05:00
|
|
|
ln -s -f ../../../devenv/bulk-dashboards/bulk-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-09-24 02:41:11 -05:00
|
|
|
bulkAlertingDashboard() {
|
|
|
|
|
|
|
|
requiresJsonnet
|
|
|
|
|
2020-04-01 13:55:37 -05:00
|
|
|
jsonnet -o "bulk_alerting_dashboards/bulk_alerting_datasources.yaml" ./bulk_alerting_dashboards/datasources.jsonnet
|
|
|
|
|
|
|
|
COUNTER=1
|
|
|
|
DS=1
|
|
|
|
MAX=1000
|
2018-09-24 02:41:11 -05:00
|
|
|
while [ $COUNTER -lt $MAX ]; do
|
2020-04-01 13:55:37 -05:00
|
|
|
jsonnet -o "bulk_alerting_dashboards/alerting_dashboard${COUNTER}.json" \
|
|
|
|
-e "local bulkDash = import 'bulk_alerting_dashboards/dashboard.libsonnet'; bulkDash.alertingDashboard(${COUNTER}, ${DS})"
|
2018-09-24 02:41:11 -05:00
|
|
|
let COUNTER=COUNTER+1
|
2020-04-01 13:55:37 -05:00
|
|
|
let DS=COUNTER/10
|
|
|
|
let DS=DS+1
|
2018-09-24 02:41:11 -05:00
|
|
|
done
|
|
|
|
|
2018-09-25 07:02:55 -05:00
|
|
|
ln -s -f ../../../devenv/bulk_alerting_dashboards/bulk_alerting_dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
|
2020-04-01 13:55:37 -05:00
|
|
|
ln -s -f ../../../devenv/bulk_alerting_dashboards/bulk_alerting_datasources.yaml ../conf/provisioning/datasources/custom.yaml
|
2018-09-24 02:41:11 -05:00
|
|
|
}
|
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
requiresJsonnet() {
|
2018-06-21 09:18:46 -05:00
|
|
|
if ! type "jsonnet" > /dev/null; then
|
|
|
|
echo "you need you install jsonnet to run this script"
|
|
|
|
echo "follow the instructions on https://github.com/google/jsonnet"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-07-16 03:53:41 -05:00
|
|
|
devDashboards() {
|
|
|
|
echo -e "\xE2\x9C\x94 Setting up all dev dashboards using provisioning"
|
2018-07-07 07:40:17 -05:00
|
|
|
ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-07-16 03:53:41 -05:00
|
|
|
devDatasources() {
|
|
|
|
echo -e "\xE2\x9C\x94 Setting up all dev datasources using provisioning"
|
2018-05-29 07:00:46 -05:00
|
|
|
|
2018-07-07 07:40:17 -05:00
|
|
|
ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
usage() {
|
2018-07-16 03:53:41 -05:00
|
|
|
echo -e "\n"
|
2018-05-29 07:00:46 -05:00
|
|
|
echo "Usage:"
|
2018-09-24 02:41:11 -05:00
|
|
|
echo " bulk-dashboards - create and provisioning 400 dashboards"
|
|
|
|
echo " bulk-alerting-dashboards - create and provisioning 400 dashboards with alerts"
|
2020-06-03 23:51:30 -05:00
|
|
|
echo " no args - provisioning core datasources and dev dashboards"
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2018-07-16 03:53:41 -05:00
|
|
|
echo -e "------------------------------------------------------------------"
|
2021-03-02 10:09:27 -06:00
|
|
|
echo -e "This script sets up provisioning for dev datasources and dashboards"
|
2018-07-16 03:53:41 -05:00
|
|
|
echo -e "------------------------------------------------------------------"
|
|
|
|
echo -e "\n"
|
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
local cmd=$1
|
|
|
|
|
2018-09-24 02:41:11 -05:00
|
|
|
if [[ $cmd == "bulk-alerting-dashboards" ]]; then
|
|
|
|
bulkAlertingDashboard
|
|
|
|
elif [[ $cmd == "bulk-dashboards" ]]; then
|
2018-05-29 07:00:46 -05:00
|
|
|
bulkDashboard
|
|
|
|
else
|
2018-07-16 03:53:41 -05:00
|
|
|
devDashboards
|
|
|
|
devDatasources
|
2018-07-07 07:40:17 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$cmd" ]]; then
|
2018-05-29 07:00:46 -05:00
|
|
|
usage
|
|
|
|
fi
|
2018-07-07 07:40:17 -05:00
|
|
|
|
2018-05-29 07:00:46 -05:00
|
|
|
}
|
|
|
|
|
2018-05-31 07:13:34 -05:00
|
|
|
main "$@"
|