From 0e59e50b39469ea8a3dd28cdc3396db030aba6ca Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Wed, 15 May 2024 11:55:13 +0530 Subject: [PATCH] Capture ttfb api metrics only for GetObject (#19733) as that is the only API where the TTFB metric is beneficial, and capturing this for all APIs exponentially increases the response size in large clusters. --- cmd/http-stats.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/http-stats.go b/cmd/http-stats.go index 077a72575..3fb528c1e 100644 --- a/cmd/http-stats.go +++ b/cmd/http-stats.go @@ -27,6 +27,10 @@ import ( "github.com/prometheus/client_golang/prometheus" ) +const ( + apiGetObject = "GetObject" +) + // connStats - Network statistics // Count total input/output transferred bytes during // the server's life. @@ -128,7 +132,7 @@ func (bh *bucketHTTPStats) updateHTTPStats(bucket, api string, w *xhttp.Response return } - if w != nil { + if w != nil && api == apiGetObject { // Increment the prometheus http request response histogram with API, Bucket bucketHTTPRequestsDuration.With(prometheus.Labels{ "api": api, @@ -433,7 +437,9 @@ func (st *HTTPStats) updateStats(api string, w *xhttp.ResponseRecorder) { st.totalS3Requests.Inc(api) // Increment the prometheus http request response histogram with appropriate label - httpRequestsDuration.With(prometheus.Labels{"api": api}).Observe(w.TimeToFirstByte.Seconds()) + if api == apiGetObject { + httpRequestsDuration.With(prometheus.Labels{"api": api}).Observe(w.TimeToFirstByte.Seconds()) + } code := w.StatusCode