From 64cd011e63a5b6685fa80637ddbaa118ce27a9de Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sat, 14 Nov 2020 11:53:51 +0100 Subject: [PATCH] Add ErrorLog plumbing to promhttp Fix the error logging of the promhttp handler by connecting it to the promlog setup. Fixes: https://github.com/prometheus/node_exporter/issues/1886 Signed-off-by: Ben Kochie --- CHANGELOG.md | 2 +- node_exporter.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27f8eefc51..6b2ed3e0b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * [FEATURE] * [ENHANCEMENT] Include TCP OutRsts in netstat metrics * [ENHANCEMENT] Added XFS inode operations to XFS metrics -* [BUGFIX] +* [BUGFIX] Add ErrorLog plumbing to promhttp ## 1.0.1 / 2020-06-15 diff --git a/node_exporter.go b/node_exporter.go index d195372efe..3af489598f 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -15,6 +15,7 @@ package main import ( "fmt" + stdlog "log" "net/http" _ "net/http/pprof" "os" @@ -121,6 +122,7 @@ func (h *handler) innerHandler(filters ...string) (http.Handler, error) { handler := promhttp.HandlerFor( prometheus.Gatherers{h.exporterMetricsRegistry, r}, promhttp.HandlerOpts{ + ErrorLog: stdlog.New(log.NewStdlibAdapter(level.Error(h.logger)), "", 0), ErrorHandling: promhttp.ContinueOnError, MaxRequestsInFlight: h.maxRequests, Registry: h.exporterMetricsRegistry,