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 "stunnel" { driver = "docker" lifecycle { hook = "prestart" sidecar = true } config { image = "alpine:3.17" args = ["/bin/sh", "$${NOMAD_TASK_DIR}/start.sh"] } resources { cpu = 100 memory = 100 } template { data = < "$LOG_FILE" exec 2>&1 GRAFANA_URL=http://127.0.0.1:3000 echo "Reload dashboards" curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/dashboards/reload echo "Reload datasources" curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/datasources/reload echo "Reload plugins" curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/plugins/reload echo "Reload notifications" curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/notifications/reload echo "Reload access-control" curl -s -S --user admin:$GF_SECURITY_ADMIN_PASSWORD --request POST $GRAFANA_URL/api/admin/provisioning/access-control/reload echo "Reload alerting" 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 = "/local/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 } } } }