2022-03-12 18:07:52 +00:00
|
|
|
job "grafana" {
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
|
|
|
|
group "grafana" {
|
|
|
|
count = 1
|
|
|
|
|
2022-07-21 22:54:05 +00:00
|
|
|
# TODO: Add backup task or job
|
|
|
|
|
2022-03-12 18:07:52 +00:00
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
|
|
|
|
port "web" {
|
|
|
|
host_network = "loopback"
|
|
|
|
to = 3000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-13 17:13:19 +00:00
|
|
|
ephemeral_disk {
|
|
|
|
migrate = true
|
|
|
|
sticky = true
|
|
|
|
}
|
|
|
|
|
2022-03-12 18:07:52 +00:00
|
|
|
service {
|
2022-03-13 17:13:19 +00:00
|
|
|
name = "grafana"
|
2022-03-12 18:07:52 +00:00
|
|
|
port = "web"
|
|
|
|
|
|
|
|
connect {
|
|
|
|
sidecar_service {
|
|
|
|
proxy {
|
|
|
|
local_service_port = 3000
|
|
|
|
|
|
|
|
upstreams {
|
|
|
|
destination_name = "prometheus"
|
|
|
|
local_bind_port = 9090
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sidecar_task {
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
check {
|
|
|
|
type = "http"
|
|
|
|
path = "/"
|
|
|
|
port = "web"
|
|
|
|
interval = "10s"
|
|
|
|
timeout = "10s"
|
|
|
|
}
|
|
|
|
|
|
|
|
tags = [
|
|
|
|
"traefik.enable=true",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
task "grafana" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "grafana/grafana:7.3.6"
|
|
|
|
ports = ["web"]
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
2022-07-21 22:54:05 +00:00
|
|
|
target = "/etc/grafana"
|
|
|
|
source = "local/config"
|
2022-03-12 18:07:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
env = {
|
|
|
|
"GF_SECURITY_ADMIN_PASSWORD" = "password",
|
|
|
|
"GF_INSTALL_PLUGINS" = "grafana-clock-panel,grafana-piechart-panel,grafana-polystat-panel",
|
|
|
|
}
|
|
|
|
|
2022-07-21 22:54:05 +00:00
|
|
|
%{ for config_file in fileset(join("/", [module_path, "grafana"]), "**") ~}
|
2022-03-12 18:07:52 +00:00
|
|
|
template {
|
|
|
|
data = <<EOF
|
2022-07-21 22:54:05 +00:00
|
|
|
${file(join("/", [module_path, "grafana", config_file]))}
|
2022-03-12 18:07:52 +00:00
|
|
|
EOF
|
|
|
|
change_mode = "signal"
|
|
|
|
change_signal = "SIGHUP"
|
2022-07-21 22:54:05 +00:00
|
|
|
destination = "local/config/${config_file}"
|
|
|
|
# Change template delimeter for dashboard files that use json and have double curly braces and square braces
|
|
|
|
%{ if length(regexall(".*/dashboard/.*", config_file)) > 0 ~}
|
|
|
|
left_delimiter = "<<<<"
|
|
|
|
right_delimiter = ">>>>"
|
|
|
|
%{ endif ~}
|
2022-03-12 18:07:52 +00:00
|
|
|
}
|
2022-07-21 22:54:05 +00:00
|
|
|
%{ endfor ~}
|
2022-03-12 18:07:52 +00:00
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 100
|
|
|
|
memory = 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|