125 lines
2.5 KiB
HCL
125 lines
2.5 KiB
HCL
job "grafana" {
|
|
datacenters = ["dc1"]
|
|
|
|
group "grafana" {
|
|
count = 1
|
|
|
|
network {
|
|
mode = "bridge"
|
|
|
|
port "web" {
|
|
host_network = "loopback"
|
|
to = 3000
|
|
}
|
|
}
|
|
|
|
service {
|
|
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",
|
|
"traefik.http.routers.grafana.entrypoints=web,websecure",
|
|
"traefik.http.routers.grafana.rule=Host(`grafana.dev.homelab`)",
|
|
"traefik.subdomain=grafana-sub",
|
|
"traefik.http.routers.grafana.tls=true",
|
|
]
|
|
}
|
|
|
|
task "grafana" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "grafana/grafana:7.3.6"
|
|
ports = ["web"]
|
|
|
|
mount {
|
|
type = "bind"
|
|
target = "/etc/grafana/grafana.ini"
|
|
source = "local/config/grafana.ini"
|
|
}
|
|
|
|
mount {
|
|
type = "bind"
|
|
target = "/etc/grafana/provisioning"
|
|
source = "local/config/provisioning"
|
|
}
|
|
}
|
|
|
|
env = {
|
|
"GF_SECURITY_ADMIN_PASSWORD" = "password",
|
|
"GF_INSTALL_PLUGINS" = "grafana-clock-panel,grafana-piechart-panel,grafana-polystat-panel",
|
|
}
|
|
|
|
template {
|
|
data = <<EOF
|
|
[paths]
|
|
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
|
|
data = /var/lib/grafana
|
|
|
|
# folder that contains provisioning config files that grafana will apply on startup and while running.
|
|
provisioning = /etc/grafana/provisioning
|
|
[server]
|
|
# Protocol (http, https, socket)
|
|
protocol = http
|
|
|
|
http_port = 3000
|
|
EOF
|
|
change_mode = "signal"
|
|
change_signal = "SIGHUP"
|
|
destination = "local/config/grafana.ini"
|
|
}
|
|
|
|
template {
|
|
data = <<EOF
|
|
---
|
|
apiVersion: 1
|
|
|
|
datasources:
|
|
- name: Prometheus
|
|
url: http://${NOMAD_UPSTREAM_ADDR_prometheus}
|
|
type: prometheus
|
|
access: proxy
|
|
isDefault: true
|
|
version: 1
|
|
EOF
|
|
change_mode = "signal"
|
|
change_signal = "SIGHUP"
|
|
destination = "local/config/provisioning/datasources/prometheus.yml"
|
|
}
|
|
|
|
resources {
|
|
cpu = 100
|
|
memory = 200
|
|
}
|
|
}
|
|
}
|
|
}
|