From 433827138b88ed2a40dbbce1bcb3ddd28a0e8691 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 1 May 2026 03:19:57 -0500 Subject: [PATCH] Fix nginx-exporter: use host network mode for direct stub_status access nginx-exporter couldn't reach host nginx via host.docker.internal (connection timeout). Switch to network_mode: host so it can access 127.0.0.1:8888 directly. Prometheus scrapes via host.docker.internal with extra_hosts mapping. Co-Authored-By: Claude Opus 4.6 (1M context) --- docker-compose.yml | 7 ++++--- monitoring/prometheus.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2285d25..cf4525a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -298,6 +298,8 @@ services: - --config.file=/etc/prometheus/prometheus.yml - --storage.tsdb.retention.time=90d - --web.enable-lifecycle + extra_hosts: + - "host.docker.internal:host-gateway" restart: unless-stopped grafana: @@ -372,9 +374,8 @@ services: nginx-exporter: image: nginx/nginx-prometheus-exporter:latest command: - - -nginx.scrape-uri=http://host.docker.internal:8888/nginx_status - extra_hosts: - - "host.docker.internal:host-gateway" + - -nginx.scrape-uri=http://127.0.0.1:8888/nginx_status + network_mode: host restart: unless-stopped blackbox-exporter: diff --git a/monitoring/prometheus.yml b/monitoring/prometheus.yml index a788af8..c93914f 100644 --- a/monitoring/prometheus.yml +++ b/monitoring/prometheus.yml @@ -42,7 +42,7 @@ scrape_configs: # ── nginx ────────────────────────────────────────────────────────── - job_name: nginx static_configs: - - targets: ["nginx-exporter:9113"] + - targets: ["host.docker.internal:9113"] # ── Blackbox probes (HTTP endpoint monitoring) ───────────────────── - job_name: blackbox_http