Fix nginx-exporter: back to bridge network with host.docker.internal

host network mode prevented Prometheus from reaching the exporter.
Switched back to bridge with extra_hosts + explicit port mapping.
Added timeout flag to prevent hanging on stub_status fetch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-01 03:21:27 -05:00
parent 433827138b
commit 0a31313956
2 changed files with 7 additions and 3 deletions

View file

@ -374,8 +374,12 @@ services:
nginx-exporter: nginx-exporter:
image: nginx/nginx-prometheus-exporter:latest image: nginx/nginx-prometheus-exporter:latest
command: command:
- -nginx.scrape-uri=http://127.0.0.1:8888/nginx_status - -nginx.scrape-uri=http://host.docker.internal:8888/nginx_status
network_mode: host - -nginx.timeout=5s
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "127.0.0.1:9113:9113"
restart: unless-stopped restart: unless-stopped
blackbox-exporter: blackbox-exporter:

View file

@ -42,7 +42,7 @@ scrape_configs:
# ── nginx ────────────────────────────────────────────────────────── # ── nginx ──────────────────────────────────────────────────────────
- job_name: nginx - job_name: nginx
static_configs: static_configs:
- targets: ["host.docker.internal:9113"] - targets: ["nginx-exporter:9113"]
# ── Blackbox probes (HTTP endpoint monitoring) ───────────────────── # ── Blackbox probes (HTTP endpoint monitoring) ─────────────────────
- job_name: blackbox_http - job_name: blackbox_http