From 8aceca784ba52e8cd625167eb1c23d78903bd83a Mon Sep 17 00:00:00 2001 From: Adam Sven Johnson Date: Tue, 19 Nov 2024 14:39:58 +1300 Subject: [PATCH] Log request remote addr in message --- middleware.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/middleware.go b/middleware.go index 9a3adb45..8d99043f 100644 --- a/middleware.go +++ b/middleware.go @@ -91,6 +91,9 @@ func monitoringMiddleware(h http.Handler) http.Handler { "request.path": r.URL.Path, "response.size": m.Written, }) + if r.RemoteAddr != "" { + event.addField("request.ip", r.RemoteAddr) + } promHTTPRequestCounter.With(prometheus.Labels{ "code": fmt.Sprintf("%dXX", m.Code/100),