Skip to content

Commit

Permalink
import jobs still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandawsonuk committed Apr 29, 2019
1 parent 0c46263 commit bb9ed78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ GRAFANA_PASS=${GF_SECURITY_ADMIN_PASSWORD}
HOST=grafana-prom
PORT=80

if [ -z "${GRAFANA_PASS}" ]
then
GRAFANA_AUTH="${GRAFANA_USER}:${GRAFANA_PASS}@"
fi

# For DEV outside of cluster
if [ ! -e /var/run/secrets/kubernetes.io/serviceaccount ]; then
HOST=localhost
Expand Down Expand Up @@ -36,9 +41,9 @@ check_connection() {
}

recreate_datasource() {
curl --silent --fail --show-error --request DELETE http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources/name/prometheus
curl --silent --fail --show-error --request DELETE http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources/name/prometheus

curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json"
curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json"
}

add_dashboard() {
Expand All @@ -50,7 +55,7 @@ add_dashboard() {
( echo '{"dashboard":';
cat "$file";
echo ',"overwrite":true,"inputs":[{"name":"'${SRC_NAME}'","type":"datasource","pluginId":"prometheus","value":"prometheus"}]}'
) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-"
) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-"

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"import-dashboards-job.sh"
],
"env": [

{{ if not (.Values.grafana_anonymous_auth) }}
{
"name": "GF_SECURITY_ADMIN_PASSWORD",
"valueFrom": {
Expand All @@ -26,7 +28,9 @@
"name": "grafana-prom-secret"
}
}
}
},
{{ end}}

],
"image": "giantswarm/tiny-tools:0.2.0",
"name": "tools",
Expand Down

0 comments on commit bb9ed78

Please sign in to comment.