diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b03aa78707..fc62887a598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6104](https://github.com/thanos-io/thanos/pull/6104) Objstore: Support S3 session token. - [#5548](https://github.com/thanos-io/thanos/pull/5548) Query: Added experimental support for load balancing across multiple Store endpoints. - [#6148](https://github.com/thanos-io/thanos/pull/6148) Query-frontend: add traceID to slow query detected log line +- [#6153](https://github.com/thanos-io/thanos/pull/6153) Query-frontend: add remote_user (from http basic auth) and remote_addr to slow query detected log line ### Fixed diff --git a/internal/cortex/frontend/transport/handler.go b/internal/cortex/frontend/transport/handler.go index e4cad320cc1..dc3dc1dd27a 100644 --- a/internal/cortex/frontend/transport/handler.go +++ b/internal/cortex/frontend/transport/handler.go @@ -177,11 +177,15 @@ func (f *Handler) reportSlowQuery(r *http.Request, responseHeaders http.Header, thanosTraceID = traceID } + remoteUser, _, _ := r.BasicAuth() + logMessage := append([]interface{}{ "msg", "slow query detected", "method", r.Method, "host", r.Host, "path", r.URL.Path, + "remote_user", remoteUser, + "remote_addr", r.RemoteAddr, "time_taken", queryResponseTime.String(), "grafana_dashboard_uid", grafanaDashboardUID, "grafana_panel_id", grafanaPanelID, @@ -200,6 +204,7 @@ func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, quer wallTime := stats.LoadWallTime() numSeries := stats.LoadFetchedSeries() numBytes := stats.LoadFetchedChunkBytes() + remoteUser, _, _ := r.BasicAuth() // Track stats. f.querySeconds.WithLabelValues(userID).Add(wallTime.Seconds()) @@ -213,6 +218,8 @@ func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, quer "component", "query-frontend", "method", r.Method, "path", r.URL.Path, + "remote_user", remoteUser, + "remote_addr", r.RemoteAddr, "response_time", queryResponseTime, "query_wall_time_seconds", wallTime.Seconds(), "fetched_series_count", numSeries,