From 4a064f3b8eceaaae41df523a9d13fa44db21e1bc Mon Sep 17 00:00:00 2001 From: oxmox Date: Sun, 17 Sep 2023 17:11:09 +0200 Subject: [PATCH] prometheus: move node-exporter to the host network for accurate traffic stats --- docker-compose.yml | 13 +++++-------- prometheus/prometheus.yml | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3e860f0..af81168 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -254,8 +254,9 @@ services: - "traefik.http.routers.prometheus_app.tls.certresolver=myresolver" - "traefik.http.routers.prometheus_app.middlewares=traefik_api_auth" - "traefik.http.services.prometheus_app.loadbalancer.server.port=9090" - #extra_hosts: - # - "host.docker.internal:host-gateway" + extra_hosts: + # To be able to reach node-exporter which listens on the host network. + - "host.docker.internal:host-gateway" grafana: image: grafana/grafana @@ -289,19 +290,15 @@ services: container_name: node-exporter restart: unless-stopped <<: *logging - #network_mode: host + # Put node-exporter on the host network to get meaningful network stats. + network_mode: host pid: host volumes: - #- /proc:/host/proc:ro - #- /sys:/host/sys:ro - /:/rootfs:ro,rslave - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro command: - #- '--path.procfs=/host/proc' - '--path.rootfs=/rootfs' - #- '--path.sysfs=/host/sys' - #- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)' expose: - 9100 diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index a1f042a..448970a 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -10,7 +10,7 @@ scrape_configs: - job_name: 'node' static_configs: - - targets: ['node-exporter:9100'] + - targets: ['host.docker.internal:9100'] - job_name: 'loki' static_configs: