|
4 | 4 | HEADER_CONTENT_TYPE="Content-Type: application/json" |
5 | 5 | HEADER_ACCEPT="Accept: application/json" |
6 | 6 |
|
| 7 | +NAMESPACE=${NAMESPACE:-drycc} |
7 | 8 | GRAFANA_USER=${DEFAULT_USER:-admin} |
8 | 9 | GRAFANA_PASSWD=${DEFAULT_USER_PASSWORD:-admin} |
9 | 10 | GRAFANA_PORT=${BIND_PORT:-3000} |
@@ -102,6 +103,52 @@ curl -i -XPOST -H "${HEADER_ACCEPT}" -H "${HEADER_CONTENT_TYPE}" "http://${GRAFA |
102 | 103 |
|
103 | 104 | echo "" |
104 | 105 | echo "Importing default dashboards..." |
| 106 | +# replace namespace |
| 107 | +# shellcheck disable=SC1003 |
| 108 | +# shellcheck disable=SC2046 |
| 109 | +sed -i 's@r\[\\"namespace\\\"\] == \\"drycc\\"@r\[\\"namespace\\"\] == \\"\'"${NAMESPACE}"'\\"@g' $(grep -F 'r[\"namespace\"] == \"drycc\"' -rl --include="*.json" "${DASHBOARD_LOCATION}") |
| 110 | +# drycc component dashboard |
| 111 | +DCD="${DASHBOARD_LOCATION}"/drycc_component_health.json |
| 112 | + |
| 113 | +# remove off-cluster component panel |
| 114 | +if [ "on-cluster" != "${INFLUXDB_LOCATION}" ]; then |
| 115 | + rm -rf "${DASHBOARD_LOCATION}"/influx.json |
| 116 | + # shellcheck disable=SC2005 |
| 117 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "INFLUXDB"))')" > "${DCD}" |
| 118 | +fi |
| 119 | +if [ "on-cluster" != "${REDIS_LOCATION}" ]; then |
| 120 | + rm -rf "${DASHBOARD_LOCATION}"/redis.json |
| 121 | + # shellcheck disable=SC2005 |
| 122 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "REDIS"))')" > "${DCD}" |
| 123 | +fi |
| 124 | +if [ "on-cluster" != "${RABBITMQ_LOCATION}" ]; then |
| 125 | + # shellcheck disable=SC2005 |
| 126 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "RABBITMQ"))')" > "${DCD}" |
| 127 | +fi |
| 128 | +if [ "on-cluster" != "${DATABASE_LOCATION}" ]; then |
| 129 | + # shellcheck disable=SC2005 |
| 130 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "DATABASE"))')" > "${DCD}" |
| 131 | +fi |
| 132 | +if [ "on-cluster" != "${PASSPORT_LOCATION}" ]; then |
| 133 | + # shellcheck disable=SC2005 |
| 134 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "PASSPORT"))')" > "${DCD}" |
| 135 | +fi |
| 136 | +if [ "on-cluster" != "${REGISTRY_LOCATION}" ]; then |
| 137 | + # shellcheck disable=SC2005 |
| 138 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "REGISTRY"))')" > "${DCD}" |
| 139 | + # shellcheck disable=SC2005 |
| 140 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "REGISTRY-PROXY"))')" > "${DCD}" |
| 141 | +fi |
| 142 | +if [ "on-cluster" != "${STORAGE_LOCATION}" ]; then |
| 143 | + rm -rf "${DASHBOARD_LOCATION}"/pd.json "${DASHBOARD_LOCATION}"/tikv.json |
| 144 | + # shellcheck disable=SC2005 |
| 145 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "STORAGE-MINIO"))')" > "${DCD}" |
| 146 | + # shellcheck disable=SC2005 |
| 147 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "STORAGE-META-PD"))')" > "${DCD}" |
| 148 | + # shellcheck disable=SC2005 |
| 149 | + echo "$(<"${DCD}" jq 'del(.dashboard.panels[] | select(.title == "STORAGE-META-TIKV"))')" > "${DCD}" |
| 150 | +fi |
| 151 | + |
105 | 152 | for filename in "${DASHBOARD_LOCATION}"/*.json; do |
106 | 153 | echo "Importing ${filename} ..." |
107 | 154 | curl -i -XPOST --data "@${filename}" -H "${HEADER_ACCEPT}" -H "${HEADER_CONTENT_TYPE}" "http://${GRAFANA_USER}:${GRAFANA_PASSWD}@localhost:${GRAFANA_PORT}/api/dashboards/db" |
|
0 commit comments