From 4e5475f7a18a172eb5273215b03cc5d1ac34ce15 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 3 Jan 2024 14:22:04 +0100 Subject: [PATCH] fix prometheus node_exporter in docker swarm mode --- roles/monitoring/templates/docker-compose.yml.j2 | 15 +++++++++------ roles/monitoring/templates/prometheus.yml.j2 | 4 +--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/roles/monitoring/templates/docker-compose.yml.j2 b/roles/monitoring/templates/docker-compose.yml.j2 index a8a44cb..f5bd9fa 100644 --- a/roles/monitoring/templates/docker-compose.yml.j2 +++ b/roles/monitoring/templates/docker-compose.yml.j2 @@ -58,14 +58,17 @@ services: max_attempts: 3 window: 120s node_exporter: - image: quay.io/prometheus/node-exporter:latest - command: - - '--path.rootfs=/host' - network_mode: host - pid: host + image: prom/node-exporter:latest restart: always volumes: - - '/:/host:ro,rslave' + - /proc:/host/proc:ro + - /sys:/host/sys:ro + - /:/rootfs:ro + command: + - '--path.procfs=/host/proc' + - '--path.rootfs=/rootfs' + - '--path.sysfs=/host/sys' + - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)' networks: {{ monitoring_network }}: deploy: diff --git a/roles/monitoring/templates/prometheus.yml.j2 b/roles/monitoring/templates/prometheus.yml.j2 index 7afd12d..fbb5903 100644 --- a/roles/monitoring/templates/prometheus.yml.j2 +++ b/roles/monitoring/templates/prometheus.yml.j2 @@ -22,7 +22,5 @@ scrape_configs: - targets: ["localhost:{{prometheus_port}}"] - job_name: node - # If prometheus-node-exporter is installed, grab stats about the local - # machine by default. static_configs: - - targets: ["node-exporter:9100"] + - targets: ["node_exporter:9100"]