From 7edc352d238cf08f854f5200cdc770cafce2e2ff Mon Sep 17 00:00:00 2001 From: Bala FA Date: Thu, 6 Jun 2024 15:06:25 +0530 Subject: [PATCH] Add ILM metrics in metrics-v3 (#19539) Signed-off-by: Bala.FA --- cmd/metrics-v2.go | 3 --- cmd/metrics-v3-ilm.go | 53 +++++++++++++++++++++++++++++++++++++++++++ cmd/metrics-v3.go | 13 +++++++++++ docs/metrics/v3.md | 18 +++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 cmd/metrics-v3-ilm.go diff --git a/cmd/metrics-v2.go b/cmd/metrics-v2.go index 1310b5da0..818ff3722 100644 --- a/cmd/metrics-v2.go +++ b/cmd/metrics-v2.go @@ -273,13 +273,10 @@ const ( vmemory = "virtual_memory_bytes" cpu = "cpu_total_seconds" - expiryPendingTasks MetricName = "expiry_pending_tasks" expiryMissedTasks MetricName = "expiry_missed_tasks" expiryMissedFreeVersions MetricName = "expiry_missed_freeversions" expiryMissedTierJournalTasks MetricName = "expiry_missed_tierjournal_tasks" expiryNumWorkers MetricName = "expiry_num_workers" - transitionPendingTasks MetricName = "transition_pending_tasks" - transitionActiveTasks MetricName = "transition_active_tasks" transitionMissedTasks MetricName = "transition_missed_immediate_tasks" transitionedBytes MetricName = "transitioned_bytes" diff --git a/cmd/metrics-v3-ilm.go b/cmd/metrics-v3-ilm.go new file mode 100644 index 000000000..604beaae7 --- /dev/null +++ b/cmd/metrics-v3-ilm.go @@ -0,0 +1,53 @@ +// Copyright (c) 2024 MinIO, Inc. +// +// # This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import ( + "context" +) + +const ( + expiryPendingTasks = "expiry_pending_tasks" + transitionActiveTasks = "transition_active_tasks" + transitionPendingTasks = "transition_pending_tasks" + transitionMissedImmediateTasks = "transition_missed_immediate_tasks" + versionsScanned = "versions_scanned" +) + +var ( + ilmExpiryPendingTasksMD = NewGaugeMD(expiryPendingTasks, "Number of pending ILM expiry tasks in the queue") + ilmTransitionActiveTasksMD = NewGaugeMD(transitionActiveTasks, "Number of active ILM transition tasks") + ilmTransitionPendingTasksMD = NewGaugeMD(transitionPendingTasks, "Number of pending ILM transition tasks in the queue") + ilmTransitionMissedImmediateTasksMD = NewCounterMD(transitionMissedImmediateTasks, "Number of missed immediate ILM transition tasks") + ilmVersionsScannedMD = NewCounterMD(versionsScanned, "Total number of object versions checked for ILM actions since server start") +) + +// loadILMMetrics - `MetricsLoaderFn` for ILM metrics. +func loadILMMetrics(_ context.Context, m MetricValues, _ *metricsCache) error { + if globalExpiryState != nil { + m.Set(expiryPendingTasks, float64(globalExpiryState.PendingTasks())) + } + if globalTransitionState != nil { + m.Set(transitionActiveTasks, float64(globalTransitionState.ActiveTasks())) + m.Set(transitionPendingTasks, float64(globalTransitionState.PendingTasks())) + m.Set(transitionMissedImmediateTasks, float64(globalTransitionState.MissedImmediateTasks())) + } + m.Set(versionsScanned, float64(globalScannerMetrics.lifetime(scannerMetricILM))) + + return nil +} diff --git a/cmd/metrics-v3.go b/cmd/metrics-v3.go index c702d52ff..c540aeef9 100644 --- a/cmd/metrics-v3.go +++ b/cmd/metrics-v3.go @@ -54,6 +54,7 @@ const ( clusterIAMCollectorPath collectorPath = "/cluster/iam" clusterConfigCollectorPath collectorPath = "/cluster/config" + ilmCollectorPath collectorPath = "/ilm" auditCollectorPath collectorPath = "/audit" loggerWebhookCollectorPath collectorPath = "/logger/webhook" replicationCollectorPath collectorPath = "/replication" @@ -382,6 +383,17 @@ func newMetricGroups(r *prometheus.Registry) *metricsV3Collection { loadAuditMetrics, ) + ilmMG := NewMetricsGroup(ilmCollectorPath, + []MetricDescriptor{ + ilmExpiryPendingTasksMD, + ilmTransitionActiveTasksMD, + ilmTransitionPendingTasksMD, + ilmTransitionMissedImmediateTasksMD, + ilmVersionsScannedMD, + }, + loadILMMetrics, + ) + allMetricGroups := []*MetricsGroup{ apiRequestsMG, bucketAPIMG, @@ -402,6 +414,7 @@ func newMetricGroups(r *prometheus.Registry) *metricsV3Collection { clusterReplicationMG, clusterConfigMG, + ilmMG, scannerMG, auditMG, loggerWebhookMG, diff --git a/docs/metrics/v3.md b/docs/metrics/v3.md index 8a89a3e83..8c2d0e40f 100644 --- a/docs/metrics/v3.md +++ b/docs/metrics/v3.md @@ -42,6 +42,14 @@ These are metrics about the minio audit functionality |----------|----------------------------------------| | `/audit` | Metrics related to audit functionality | +### ILM metrics + +These are metrics about the minio ILM functionality + +| Path | Description | +|--------|--------------------------------------| +| `/ilm` | Metrics related to ILM functionality | + ### Logger webhook metrics These are metrics about the minio logger webhooks @@ -377,3 +385,13 @@ The standard metrics group for GoCollector is not shown below. | `minio_scanner_last_activity_seconds` | `gauge` | Time elapsed (in seconds) since last scan activity | `server` | | `minio_scanner_objects_scanned` | `counter` | Total number of unique objects scanned since server start | `server` | | `minio_scanner_versions_scanned` | `counter` | Total number of object versions scanned since server start | `server` | + +### `/ilm` + +| Name | Type | Help | Labels | +|-------------------------------------------------------|-----------|----------------------------------------------------------------------------|----------| +| `minio_cluster_ilm_expiry_pending_tasks` | `gauge` | Number of pending ILM expiry tasks in the queue | `server` | +| `minio_cluster_ilm_transition_active_tasks` | `gauge` | Number of active ILM transition tasks | `server` | +| `minio_cluster_ilm_transition_pending_tasks` | `gauge` | Number of pending ILM transition tasks in the queue | `server` | +| `minio_cluster_ilm_transition_missed_immediate_tasks` | `counter` | Number of missed immediate ILM transition tasks | `server` | +| `minio_cluster_ilm_versions_scanned` | `counter` | Total number of object versions checked for ILM actions since server start | `server` |