Repository navigation
fix: honor LISTEN when metrics are pushed - #375
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ListenAddress flag configuration to conditionally default to 0.0.0.0:80 or 127.0.0.1:10300 depending on whether a metrics endpoint is configured. Additionally, it ensures that a failure to start the local HTTP server does not stop the agent when metrics are being pushed. Feedback suggests using klog.Exitln instead of klog.Errorln when the metrics endpoint is not configured, ensuring the agent exits with a non-zero status so that orchestrators can detect the failure and restart it.
blue4209211
approved these changes
Oct 8, 2026
With --metrics-endpoint set, the listen address was forced to 127.0.0.1:10300 even when LISTEN or --listen was given, and a taken port made the agent exit, so two pushing agents could not share a host and a port conflict stopped all collection. LISTEN now wins whenever it is set; unset, the defaults stay as before (0.0.0.0:80, or 127.0.0.1:10300 when pushing). When pushing, a failed bind is logged and the agent keeps running, since nothing scrapes the endpoint.
In scrape mode a failed bind made main return, so the agent exited 0 and a service manager restarting only on failure would leave it down.
mayankpande88
force-pushed
the
fix/listen-in-push-mode
branch
from
October 8, 2026 09:18
2649bf3 to
bf5fc20
Compare
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.
Summary
When metrics are pushed (
--metrics-endpoint/METRICS_ENDPOINT), the agent forced its HTTP endpoint onto127.0.0.1:10300and ignoredLISTEN/--listen. If that port was taken, the agent exited and stopped collecting entirely. On a host that pushes, a port conflict therefore cost all data, and two pushing agents couldn't run side by side.LISTEN/--listenis now honoured whenever it is set.0.0.0.0:80, or127.0.0.1:10300when pushing.Engineering detail
Change:
--listenno longer has a hard default.flags.initfills it in only when it's empty, so an explicit value always wins. The 10300 override came from 1faeef3.Compatibility: the Kubernetes deployment doesn't set
LISTEN, so it keeps0.0.0.0:80when scraped and127.0.0.1:10300when pushing.install.shonly passesLISTENthrough if the user sets it.CI: gofmt, goimports, vet, golangci-lint,
go test(excluding/containers) and the build all pass in a Linux container with Go 1.26.5.Local e2e: I built agent binaries from this branch and from main and ran them as systemd services on a local Debian 12 VM (kernel 6.1), pushing to a local VictoriaMetrics.
LISTEN: both builds listened on 127.0.0.1:10300.LISTEN=127.0.0.1:10352: this branch listened on :10352; main still listened on 127.0.0.1:10300.LISTEN: this branch listened on :80.