diff --git a/core/metrics/grafana.nomad b/core/metrics/grafana.nomad index ed684b4..d1e6ed9 100644 --- a/core/metrics/grafana.nomad +++ b/core/metrics/grafana.nomad @@ -11,12 +11,6 @@ job "grafana" { host_network = "wesher" to = 3000 } - - # TODO: Not sure if this needs to be mapped here since it's within the group - port "renderer" { - host_network = "loopback" - to = 8081 - } } ephemeral_disk { @@ -96,16 +90,12 @@ SELECT 'NOOP'; config { image = "grafana/grafana:9.4.2" ports = ["web"] - - mount { - type = "bind" - target = "/etc/grafana" - source = "local/config" - } } env = { "GF_INSTALL_PLUGINS" = "grafana-clock-panel,grafana-piechart-panel,grafana-polystat-panel,natel-discrete-panel", + "GF_PATHS_CONFIG" = "$${NOMAD_ALLOC_DIR}/config/grafana.ini" + "GF_PATHS_PROVISIONING" = "$${NOMAD_ALLOC_DIR}/config/provisioning" } template { @@ -136,14 +126,79 @@ SLACK_HOOK_URL={{ .slack_hook_url }} destination = "secrets/conf.env" } + resources { + cpu = 100 + memory = 200 + } + } + + task "grafana-reprovisioner" { + driver = "docker" + + lifecycle { + hook = "prestart" + sidecar = true + } + + config { + image = "alpine" + args = ["$${NOMAD_TASK_DIR}/startup.sh"] + } + + resources { + cpu = 100 + memory = 100 + } + + env = { + LOG_FILE = "/var/log/grafana_reloader.log" + } + + 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 = <