Repository navigation
Description
What
Setting global.metrics_port: 0 to turn the metrics endpoint off leaves it listening on 8080.
metrics.NewCollector treats any non-positive port as unset and fills it from the defaults
(internal/metrics/collector.go:94-96):
defaults := DefaultConfig()
if config.Port <= 0 {
config.Port = defaults.Port // 8080
}Verified
RESULT: Port:0 defaulted to 8080 and BOUND it — port 0 does NOT disable
RESULT: Enabled:false bound nothing — this is the disable switch
(Constructed a collector with Enabled: true, Port: 0, called Start, then dialled
127.0.0.1:8080 in a loop for 2s.)
Nothing in Configuration.Validate() rejects port 0, so the config loads clean and the mount logs
metrics server started port=8080 — which an operator who wrote 0 is unlikely to read as
contradicting what they asked for.
Why it matters
0 is the conventional "disabled" value for a port, and this repo already uses it that way one
field over: internal/adapter/adapter.go:207 gates the health listener on
HTTPEnabled: a.config.Global.HealthPort > 0. So health_port: 0 disables and metrics_port: 0
does not, which is worse than either behaviour on its own — the operator has no reason to expect the
two adjacent fields to differ.
The failure direction is the bad one: someone trying to close a network port ends up with it open on
the default. That is the same class as the withdrawn v0.10.0 at_rest: true key — a configuration
value that reads as a security decision and isn't one.
Proposed
Pick one and make both ports agree:
0means off for both, matchinghealth_portand the convention.NewCollector's
defaulting then needs to distinguish "unset" from "explicitly zero" — the honest way is for the
adapter to gate the call the way it already gates health, rather than for the collector to guess.0is invalid for both, rejected inValidate()naming the field, withenabled: falseas
the only way to disable.
(1) is better: it is what the adjacent field already does, and it is what an operator will try
first.
Either way Validate() should reject a port outside 1–65535 rather than letting it reach a
net.Listen that fails on a goroutine — Collector.Start's listener error is logged from inside a
go func() and nothing propagates it, so a bad port today is a silent no-endpoint.
Also worth a test asserting the two fields behave the same way, since the whole defect is that they
don't.
Related: #211 (both listeners bind all interfaces).
Activity
fix: one address per listener, beside the flag that enables it (#246)
scttfrdmn commentedon Aug 3, 2026
Fixed and shipped in the v0.11.0 Unreleased changelog, and fixed by removing the setting rather than by special-casing zero.
There is no
0in an address.global.metrics_portandglobal.health_portare gone, replaced bymonitoring.metrics.addrandmonitoring.health_checks.addr, and each listener'senabledflag sits directly beside itsaddr— so turning an endpoint off isenabled: falseand only that.That is the fix this issue was asking for at its root. A port had two spellings of "off" that disagreed:
health_port: 0disabled its listener, whilemetrics_port: 0read as unset, defaulted back to 8080, and bound it — two adjacent fields, and the metrics one failed in the direction that leaves a port open. An address subsumes a port, so keeping both would have preserved the disagreement.Validation came with it:
net.SplitHostPortaccepts"99999", so the port range is checked explicitly and the error names the field.health_port: 99999used to reachnet.Listenstraight from YAML.Recorded in
SECURITY.mdunder Turning a listener off isenabled: false, and only that, so the old behavior is documented as history rather than forgotten.