225 lines
4.5 KiB
HCL
225 lines
4.5 KiB
HCL
job "metrics" {
|
|
datacenters = ["dc1"]
|
|
type = "system"
|
|
|
|
group "exporters" {
|
|
|
|
network {
|
|
mode = "bridge"
|
|
|
|
port "cadvisor" {
|
|
host_network = "nomad-bridge"
|
|
to = 8080
|
|
}
|
|
|
|
port "node_exporter" {
|
|
host_network = "nomad-bridge"
|
|
to = 9100
|
|
}
|
|
|
|
port "promtail" {
|
|
host_network = "nomad-bridge"
|
|
to = 9080
|
|
}
|
|
|
|
port "expose" {
|
|
host_network = "nomad-bridge"
|
|
}
|
|
|
|
port "cadvisor_envoy_metrics" {
|
|
host_network = "nomad-bridge"
|
|
to = 9102
|
|
}
|
|
}
|
|
|
|
service {
|
|
name = "cadvisor"
|
|
port = "cadvisor"
|
|
|
|
meta {
|
|
metrics_addr = "${NOMAD_ADDR_expose}"
|
|
envoy_metrics_addr = "${NOMAD_ADDR_cadvisor_envoy_metrics}"
|
|
nomad_dc = "${NOMAD_DC}"
|
|
nomad_node_name = "${node.unique.name}"
|
|
}
|
|
|
|
connect {
|
|
sidecar_service {
|
|
proxy {
|
|
local_service_port = 8080
|
|
|
|
expose {
|
|
path {
|
|
path = "/metrics"
|
|
protocol = "http"
|
|
local_path_port = 8080
|
|
listener_port = "expose"
|
|
}
|
|
}
|
|
|
|
config {
|
|
envoy_prometheus_bind_addr = "0.0.0.0:9102"
|
|
}
|
|
}
|
|
}
|
|
|
|
sidecar_task {
|
|
resources {
|
|
cpu = 50
|
|
memory = 50
|
|
}
|
|
}
|
|
}
|
|
|
|
check {
|
|
type = "http"
|
|
path = "/metrics"
|
|
port = "cadvisor"
|
|
interval = "10s"
|
|
timeout = "10s"
|
|
}
|
|
|
|
// TODO: Remove traefik tags
|
|
tags = [
|
|
"traefik.enable=true",
|
|
"traefik.http.routers.cadvisor.entrypoints=web,websecure",
|
|
"traefik.http.routers.cadvisor.rule=Host(`cadvisor.dev.homelab`)",
|
|
"traefik.http.routers.cadvisor.tls=true",
|
|
]
|
|
}
|
|
|
|
task "cadvisor" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
# image = "iamthefij/cadvisor:0.37.5"
|
|
image = "gcr.io/cadvisor/cadvisor:v0.39.3"
|
|
args = ["--docker_only=true"]
|
|
|
|
ports = ["cadvisor"]
|
|
|
|
# volumes = [
|
|
# "/:/rootfs:ro",
|
|
# "/var/run:/var/run:rw",
|
|
# "/sys:/sys:ro",
|
|
# "/var/lib/docker/:/var/lib/docker:ro",
|
|
# "/cgroup:/cgroup:ro",
|
|
# "/etc/machine-id:/etc/machine-id:ro",
|
|
# ]
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/"
|
|
target = "/rootfs"
|
|
readonly = true
|
|
}
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/var/run"
|
|
target = "/var/run"
|
|
readonly = false
|
|
}
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/sys"
|
|
target = "/sys"
|
|
readonly = true
|
|
}
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/var/lib/docker"
|
|
target = "/var/lib/docker"
|
|
readonly = true
|
|
}
|
|
|
|
# mount {
|
|
# type = "bind"
|
|
# source = "/cgroup"
|
|
# target = "/cgroup"
|
|
# readonly = true
|
|
# }
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/etc/machine-id"
|
|
target = "/etc/machine-id"
|
|
readonly = true
|
|
}
|
|
}
|
|
|
|
resources {
|
|
cpu = 50
|
|
memory = 100
|
|
}
|
|
}
|
|
|
|
service {
|
|
name = "nodeexporter"
|
|
port = "node_exporter"
|
|
|
|
meta {
|
|
metrics_addr = "${NOMAD_ADDR_node_exporter}"
|
|
nomad_dc = "${NOMAD_DC}"
|
|
nomad_node_name = "${node.unique.name}"
|
|
}
|
|
|
|
connect {
|
|
sidecar_service {
|
|
proxy {
|
|
local_service_port = 9100
|
|
}
|
|
}
|
|
|
|
sidecar_task {
|
|
resources {
|
|
cpu = 50
|
|
memory = 50
|
|
}
|
|
}
|
|
}
|
|
|
|
check {
|
|
type = "http"
|
|
path = "/metrics"
|
|
port = "node_exporter"
|
|
interval = "10s"
|
|
timeout = "10s"
|
|
}
|
|
|
|
// TODO: Remove traefik tags
|
|
tags = [
|
|
"traefik.enable=true",
|
|
"traefik.http.routers.node_exporter.entrypoints=web,websecure",
|
|
"traefik.http.routers.node_exporter.rule=Host(`node_exporter.dev.homelab`)",
|
|
"traefik.http.routers.node_exporter.tls=true",
|
|
]
|
|
}
|
|
|
|
task "node_exporter" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "prom/node-exporter:v1.0.1"
|
|
args = ["--path.rootfs", "/host"]
|
|
|
|
ports = ["node_exporter"]
|
|
|
|
mount {
|
|
type = "bind"
|
|
source = "/"
|
|
target = "/host"
|
|
readonly = true
|
|
}
|
|
}
|
|
|
|
resources {
|
|
cpu = 50
|
|
memory = 50
|
|
}
|
|
}
|
|
}
|
|
}
|