65 lines
1.3 KiB
Terraform
65 lines
1.3 KiB
Terraform
|
data "docker_registry_image" "node_exporter" {
|
||
|
name = "prom/node-exporter"
|
||
|
}
|
||
|
|
||
|
locals {
|
||
|
labels_node_exporter = {
|
||
|
"shepherd.auto-update" = "true",
|
||
|
"prometheus.job" = "node",
|
||
|
"prometheus.port" = "9100",
|
||
|
}
|
||
|
}
|
||
|
|
||
|
resource "docker_service" "node_exporter" {
|
||
|
name = "prometheus_node_exporter"
|
||
|
|
||
|
mode {
|
||
|
global = true
|
||
|
}
|
||
|
|
||
|
dynamic "labels" {
|
||
|
for_each = local.labels_node_exporter
|
||
|
content {
|
||
|
label = labels.key
|
||
|
value = labels.value
|
||
|
}
|
||
|
}
|
||
|
|
||
|
task_spec {
|
||
|
networks_advanced {
|
||
|
name = docker_network.metrics.id
|
||
|
}
|
||
|
|
||
|
container_spec {
|
||
|
image = "${data.docker_registry_image.node_exporter.name}@${data.docker_registry_image.node_exporter.sha256_digest}"
|
||
|
|
||
|
args = [
|
||
|
"--path.rootfs=/host/root",
|
||
|
"--path.procfs=/host/proc",
|
||
|
"--path.sysfs=/host/sys",
|
||
|
"--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($|/)"
|
||
|
]
|
||
|
mounts {
|
||
|
target = "/host/root"
|
||
|
source = "/"
|
||
|
type = "bind"
|
||
|
read_only = true
|
||
|
}
|
||
|
|
||
|
mounts {
|
||
|
target = "/host/proc"
|
||
|
source = "/proc"
|
||
|
type = "bind"
|
||
|
read_only = true
|
||
|
}
|
||
|
|
||
|
mounts {
|
||
|
target = "/host/sys"
|
||
|
source = "/sys"
|
||
|
type = "bind"
|
||
|
read_only = true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|