job "grafana" { datacenters = ["dc1"] group "grafana" { count = 1 network { mode = "bridge" port "web" { host_network = "wesher" to = 3000 } } ephemeral_disk { migrate = true sticky = true } service { name = "grafana" provider = "nomad" port = "web" tags = [ "traefik.enable=true", "traefik.http.routers.grafana.entryPoints=websecure", ] } task "grafana-bootstrap" { driver = "docker" lifecycle { hook = "prestart" sidecar = false } config { image = "mariadb:10" args = [ "/bin/bash", "-c", "/usr/bin/mysql --defaults-extra-file=$${NOMAD_SECRETS_DIR}/my.cnf < $${NOMAD_SECRETS_DIR}/bootstrap.sql", ] } template { data = < "$LOG_FILE" exec 2>&1 GRAFANA_URL=http://127.0.0.1:3000 curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/dashboards/reload curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/datasources/reload curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/plugins/reload curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/notifications/reload curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/access-control/reload curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/alerting/reload EOF change_mode = "noop" perms = "777" destination = "$${NOMAD_TASK_DIR}/reload_config.sh" } %{ for config_file in fileset(join("/", [module_path, "grafana"]), "**") ~} template { data = < 0 ~} left_delimiter = "<<<<" right_delimiter = ">>>>" %{ endif } change_mode = "script" change_script { command = "$${NOMAD_TASK_DIR}/reload_config.sh" } } %{ endfor } } task "grafana-image-renderer" { driver = "docker" config { image = "grafana/grafana-image-renderer:3.6.1" ports = ["renderer"] } env = { "RENDERING_MODE" = "clustered" "RENDERING_CLUSTERING_MODE" = "browser" "RENDERING_CLUSTERING_MAX_CONCURRENCY" = 5 "RENDERING_CLUSTERING_TIMEOUT" = 30 } } } }