From ad69b9907fb9a1d59d008953276dab5c6e9a44c3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 6 Sep 2023 12:50:46 -0700 Subject: [PATCH] fix: report bucket metrics for only existing buckets (#17987) --- cmd/handler-utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index 92c0eb1e7..830f5daac 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -300,7 +300,8 @@ func collectAPIStats(api string, f http.HandlerFunc) http.HandlerFunc { globalHTTPStats.currentS3Requests.Inc(api) defer globalHTTPStats.currentS3Requests.Dec(api) - if bucket != "" && bucket != minioReservedBucket { + _, err = globalBucketMetadataSys.Get(bucket) // check if this bucket exists. + if bucket != "" && bucket != minioReservedBucket && err == nil { globalBucketHTTPStats.updateHTTPStats(bucket, api, nil) } @@ -316,7 +317,7 @@ func collectAPIStats(api string, f http.HandlerFunc) http.HandlerFunc { globalConnStats.incS3InputBytes(int64(tc.RequestRecorder.Size())) globalConnStats.incS3OutputBytes(int64(tc.ResponseRecorder.Size())) - if bucket != "" && bucket != minioReservedBucket { + if bucket != "" && bucket != minioReservedBucket && err == nil { globalBucketConnStats.incS3InputBytes(bucket, int64(tc.RequestRecorder.Size())) globalBucketConnStats.incS3OutputBytes(bucket, int64(tc.ResponseRecorder.Size())) globalBucketHTTPStats.updateHTTPStats(bucket, api, tc.ResponseRecorder)