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) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-01 03:19:57 -05:00
parent 27cc925c4d
commit 433827138b
2 changed files with 5 additions and 4 deletions

View file

@ -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:

View file

@ -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