monitoring: derive nginx_exporter_listen from per-host wg_ip#39
Merged
Conversation
The default `nginx_exporter_listen: "10.10.0.2:9113"` hardcoded the first RU's WG address. With multiple RUs in groups['ru'] (live as of 2026-05-06), the second RU tried to bind 10.10.0.2:9113 — an address not assigned to its interface — and entered a systemd restart loop: HTTP server failed: listen tcp 10.10.0.2:9113: bind: cannot assign requested address vmagent's scrape_configs already uses `hostvars[h].wg_ip | default(wg_ru_ip)` per-host (vmagent-scrape.yml.j2), and node_exporter's listen address derives the same way. Bring nginx_exporter into line with that pattern so a fresh role apply on any RU produces a unit file that binds the local WG IP. Behaviour: * vm_my_ru (wg_ip=10.10.0.2) → listen 10.10.0.2:9113 (unchanged) * vm_my_ru2 (wg_ip=10.10.0.3) → listen 10.10.0.3:9113 (was broken) * future RUs auto-correct from inventory entry. Tested by re-deploying on vm_my_ru2: service active, port bound, metrics flow to vmagent → VictoriaMetrics. Grafana dashboards already group by instance label so multi-RU panels populate automatically. Signed-off-by: findias <findias@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
nginx_exporter_listendefaulted to a hardcoded10.10.0.2:9113— the first RU's WG address. With multiple RUs ingroups['ru'](live as of 2026-05-06), the second RU tried to bind to an address not assigned to its interface and entered a systemd restart loop:Fix
Derive listen address from per-host
wg_ipwith the samedefault(wg_ru_ip)fallback that scrape configs and node_exporter already use:vmagent's
vmagent-scrape.yml.j2already iteratesgroups['ru']with the same expression, so listening + scraping stay in lockstep on each RU.Behaviour
vm_my_ru(wg_ip=10.10.0.2) → listen10.10.0.2:9113(unchanged)vm_my_ru2(wg_ip=10.10.0.3) → listen10.10.0.3:9113(was broken)Test plan
vm_my_ru2: service goes fromactivating(restart loop) toactive, port binds, metrics return.groups['ru']loop, pushes to VictoriaMetrics.up{job="nginx-vm_my_ru2", instance="5.8.50.41"}reports.vm_my_rucontinues to work becausewg_ip: 10.10.0.2in inventory matches the previous hardcoded default — the new expression resolves to the same value for it.