From eff0ea43aa4801292980143fdf50aa609fddaf3b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 14 Jul 2024 11:11:42 -0700 Subject: [PATCH] fix: typo in BucketUsageMetrics group registration in v3 metrics (#20090) ``` curl http://localhost:9000/minio/metrics/v3/cluster/usage/buckets ``` Did not work as documented, due to the fact that there was a typo in the bucket usage metrics registration group. This endpoint is a cluster endpoint and does not require any `buckets` argument. --- cmd/metrics-v3-cluster-usage.go | 8 ++------ cmd/metrics-v3-handler.go | 2 +- cmd/metrics-v3.go | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cmd/metrics-v3-cluster-usage.go b/cmd/metrics-v3-cluster-usage.go index 653b127a4..614d30d13 100644 --- a/cmd/metrics-v3-cluster-usage.go +++ b/cmd/metrics-v3-cluster-usage.go @@ -139,7 +139,7 @@ var ( ) // loadClusterUsageBucketMetrics - `MetricsLoaderFn` to load bucket usage metrics. -func loadClusterUsageBucketMetrics(ctx context.Context, m MetricValues, c *metricsCache, buckets []string) error { +func loadClusterUsageBucketMetrics(ctx context.Context, m MetricValues, c *metricsCache) error { dataUsageInfo, err := c.dataUsageInfo.Get() if err != nil { metricsLogIf(ctx, err) @@ -153,11 +153,7 @@ func loadClusterUsageBucketMetrics(ctx context.Context, m MetricValues, c *metri m.Set(usageSinceLastUpdateSeconds, float64(time.Since(dataUsageInfo.LastUpdate))) - for _, bucket := range buckets { - usage, ok := dataUsageInfo.BucketsUsage[bucket] - if !ok { - continue - } + for bucket, usage := range dataUsageInfo.BucketsUsage { quota, err := globalBucketQuotaSys.Get(ctx, bucket) if err != nil { // Log and continue if we are unable to retrieve metrics for this diff --git a/cmd/metrics-v3-handler.go b/cmd/metrics-v3-handler.go index 24dcf838f..68a3160d5 100644 --- a/cmd/metrics-v3-handler.go +++ b/cmd/metrics-v3-handler.go @@ -163,7 +163,7 @@ func (h *metricsV3Server) handle(path string, isListingRequest bool, buckets []s http.Error(w, "Metrics Resource Not found", http.StatusNotFound) }) - // Require that metrics path has at least component. + // Require that metrics path has one component at least. if path == "/" { return notFoundHandler } diff --git a/cmd/metrics-v3.go b/cmd/metrics-v3.go index c540aeef9..d00a447d3 100644 --- a/cmd/metrics-v3.go +++ b/cmd/metrics-v3.go @@ -270,7 +270,7 @@ func newMetricGroups(r *prometheus.Registry) *metricsV3Collection { loadClusterUsageObjectMetrics, ) - clusterUsageBucketsMG := NewBucketMetricsGroup(clusterUsageBucketsCollectorPath, + clusterUsageBucketsMG := NewMetricsGroup(clusterUsageBucketsCollectorPath, []MetricDescriptor{ usageSinceLastUpdateSecondsMD, usageBucketTotalBytesMD,