Do not log client scrape disconnects as errors#331
Open
gecube wants to merge 1 commit into
Open
Conversation
When a scraper (e.g. Prometheus) closes the connection before the /metrics response is fully written, promhttp calls the configured ErrorLog once per metric family, flooding the log with "error encoding and sending metric family: ... write: broken pipe" lines for a single benign event (a scrape timeout or the scraper restarting). Detect EPIPE/ECONNRESET in the promhttp error logger and log those at V(1) instead of the error stream. Genuine encoding/gathering errors are still logged as errors. Signed-off-by: Gaál György <gb12335@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.
Problem
When a scraper (e.g. Prometheus) closes the
/metricsconnection before the response is fully written,promhttpinvokes the configuredErrorLogonce per metric family. A single benign event — a scrape timeout or the scraper restarting — floods the log with dozens of identical lines:This is a client-side disconnect (the agent is being scraped and the peer went away mid-response), not an agent fault, but it is reported at error level and is easily mistaken for a real failure. See #289.
Change
Detect
EPIPE/ECONNRESETin the promhttp error logger and log those atV(1)instead of the error stream. Genuine encoding/gathering errors continue to be logged as errors.