| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | // Copyright (c) 2015-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 <http://www.gnu.org/licenses/>.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"slices" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/prometheus/client_golang/prometheus" | 
					
						
							|  |  |  | 	"github.com/prometheus/client_golang/prometheus/collectors" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Collector paths.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // These are paths under the top-level /minio/metrics/v3 metrics endpoint. Each
 | 
					
						
							|  |  |  | // of these paths returns a set of V3 metrics.
 | 
					
						
							| 
									
										
										
										
											2024-05-03 01:37:57 +08:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Per-bucket metrics endpoints always start with /bucket and the bucket name is
 | 
					
						
							|  |  |  | // appended to the path. e.g. if the collector path is /bucket/api, the endpoint
 | 
					
						
							|  |  |  | // for the bucket "mybucket" would be /minio/metrics/v3/bucket/api/mybucket
 | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | const ( | 
					
						
							|  |  |  | 	apiRequestsCollectorPath collectorPath = "/api/requests" | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bucketAPICollectorPath         collectorPath = "/bucket/api" | 
					
						
							|  |  |  | 	bucketReplicationCollectorPath collectorPath = "/bucket/replication" | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	systemNetworkInternodeCollectorPath collectorPath = "/system/network/internode" | 
					
						
							|  |  |  | 	systemDriveCollectorPath            collectorPath = "/system/drive" | 
					
						
							| 
									
										
										
										
											2024-04-17 13:10:25 +08:00
										 |  |  | 	systemMemoryCollectorPath           collectorPath = "/system/memory" | 
					
						
							| 
									
										
										
										
											2024-04-24 07:56:12 +08:00
										 |  |  | 	systemCPUCollectorPath              collectorPath = "/system/cpu" | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	systemProcessCollectorPath          collectorPath = "/system/process" | 
					
						
							| 
									
										
										
										
											2024-05-14 15:25:37 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	debugGoCollectorPath collectorPath = "/debug/go" | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	clusterHealthCollectorPath       collectorPath = "/cluster/health" | 
					
						
							|  |  |  | 	clusterUsageObjectsCollectorPath collectorPath = "/cluster/usage/objects" | 
					
						
							|  |  |  | 	clusterUsageBucketsCollectorPath collectorPath = "/cluster/usage/buckets" | 
					
						
							|  |  |  | 	clusterErasureSetCollectorPath   collectorPath = "/cluster/erasure-set" | 
					
						
							| 
									
										
										
										
											2024-05-02 16:20:42 +08:00
										 |  |  | 	clusterIAMCollectorPath          collectorPath = "/cluster/iam" | 
					
						
							| 
									
										
										
										
											2024-05-24 20:50:46 +08:00
										 |  |  | 	clusterConfigCollectorPath       collectorPath = "/cluster/config" | 
					
						
							| 
									
										
										
										
											2024-05-10 22:50:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-06 17:36:25 +08:00
										 |  |  | 	ilmCollectorPath           collectorPath = "/ilm" | 
					
						
							| 
									
										
										
										
											2024-05-14 15:27:33 +08:00
										 |  |  | 	auditCollectorPath         collectorPath = "/audit" | 
					
						
							|  |  |  | 	loggerWebhookCollectorPath collectorPath = "/logger/webhook" | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 	replicationCollectorPath   collectorPath = "/replication" | 
					
						
							| 
									
										
										
										
											2024-05-24 19:10:24 +08:00
										 |  |  | 	notificationCollectorPath  collectorPath = "/notification" | 
					
						
							| 
									
										
										
										
											2024-05-25 03:29:25 +08:00
										 |  |  | 	scannerCollectorPath       collectorPath = "/scanner" | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							|  |  |  | 	clusterBasePath = "/cluster" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type metricsV3Collection struct { | 
					
						
							|  |  |  | 	mgMap       map[collectorPath]*MetricsGroup | 
					
						
							|  |  |  | 	bucketMGMap map[collectorPath]*MetricsGroup | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Gatherers for non-bucket MetricsGroup's
 | 
					
						
							|  |  |  | 	mgGatherers map[collectorPath]prometheus.Gatherer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	collectorPaths []collectorPath | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func newMetricGroups(r *prometheus.Registry) *metricsV3Collection { | 
					
						
							|  |  |  | 	// Create all metric groups.
 | 
					
						
							|  |  |  | 	apiRequestsMG := NewMetricsGroup(apiRequestsCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			apiRejectedAuthTotalMD, | 
					
						
							|  |  |  | 			apiRejectedHeaderTotalMD, | 
					
						
							|  |  |  | 			apiRejectedTimestampTotalMD, | 
					
						
							|  |  |  | 			apiRejectedInvalidTotalMD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			apiRequestsWaitingTotalMD, | 
					
						
							|  |  |  | 			apiRequestsIncomingTotalMD, | 
					
						
							|  |  |  | 			apiRequestsInFlightTotalMD, | 
					
						
							|  |  |  | 			apiRequestsTotalMD, | 
					
						
							|  |  |  | 			apiRequestsErrorsTotalMD, | 
					
						
							|  |  |  | 			apiRequests5xxErrorsTotalMD, | 
					
						
							|  |  |  | 			apiRequests4xxErrorsTotalMD, | 
					
						
							|  |  |  | 			apiRequestsCanceledTotalMD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			apiRequestsTTFBSecondsDistributionMD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			apiTrafficSentBytesMD, | 
					
						
							|  |  |  | 			apiTrafficRecvBytesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		JoinLoaders(loadAPIRequestsHTTPMetrics, loadAPIRequestsTTFBMetrics, | 
					
						
							|  |  |  | 			loadAPIRequestsNetworkMetrics), | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 	bucketAPIMG := NewBucketMetricsGroup(bucketAPICollectorPath, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 		[]MetricDescriptor{ | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 			bucketAPITrafficRecvBytesMD, | 
					
						
							|  |  |  | 			bucketAPITrafficSentBytesMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 			bucketAPIRequestsInFlightMD, | 
					
						
							|  |  |  | 			bucketAPIRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketAPIRequestsCanceledMD, | 
					
						
							|  |  |  | 			bucketAPIRequests4xxErrorsMD, | 
					
						
							|  |  |  | 			bucketAPIRequests5xxErrorsMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 			bucketAPIRequestsTTFBSecondsDistributionMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		JoinBucketLoaders(loadBucketAPIHTTPMetrics, loadBucketAPITTFBMetrics), | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bucketReplicationMG := NewBucketMetricsGroup(bucketReplicationCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			bucketReplLastHrFailedBytesMD, | 
					
						
							|  |  |  | 			bucketReplLastHrFailedCountMD, | 
					
						
							|  |  |  | 			bucketReplLastMinFailedBytesMD, | 
					
						
							|  |  |  | 			bucketReplLastMinFailedCountMD, | 
					
						
							|  |  |  | 			bucketReplLatencyMsMD, | 
					
						
							|  |  |  | 			bucketReplProxiedDeleteTaggingRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketReplProxiedGetRequestsFailuresMD, | 
					
						
							|  |  |  | 			bucketReplProxiedGetRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketReplProxiedGetTaggingRequestsFailuresMD, | 
					
						
							|  |  |  | 			bucketReplProxiedGetTaggingRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketReplProxiedHeadRequestsFailuresMD, | 
					
						
							|  |  |  | 			bucketReplProxiedHeadRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketReplProxiedPutTaggingRequestsFailuresMD, | 
					
						
							|  |  |  | 			bucketReplProxiedPutTaggingRequestsTotalMD, | 
					
						
							|  |  |  | 			bucketReplSentBytesMD, | 
					
						
							|  |  |  | 			bucketReplSentCountMD, | 
					
						
							|  |  |  | 			bucketReplTotalFailedBytesMD, | 
					
						
							|  |  |  | 			bucketReplTotalFailedCountMD, | 
					
						
							|  |  |  | 			bucketReplProxiedDeleteTaggingRequestsFailuresMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 		loadBucketReplicationMetrics, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	systemNetworkInternodeMG := NewMetricsGroup(systemNetworkInternodeCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			internodeErrorsTotalMD, | 
					
						
							|  |  |  | 			internodeDialedErrorsTotalMD, | 
					
						
							|  |  |  | 			internodeDialAvgTimeNanosMD, | 
					
						
							|  |  |  | 			internodeSentBytesTotalMD, | 
					
						
							|  |  |  | 			internodeRecvBytesTotalMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadNetworkInternodeMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-17 13:10:25 +08:00
										 |  |  | 	systemMemoryMG := NewMetricsGroup(systemMemoryCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			memTotalMD, | 
					
						
							|  |  |  | 			memUsedMD, | 
					
						
							|  |  |  | 			memFreeMD, | 
					
						
							|  |  |  | 			memAvailableMD, | 
					
						
							|  |  |  | 			memBuffersMD, | 
					
						
							|  |  |  | 			memCacheMD, | 
					
						
							|  |  |  | 			memSharedMD, | 
					
						
							|  |  |  | 			memUsedPercMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadMemoryMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 07:56:12 +08:00
										 |  |  | 	systemCPUMG := NewMetricsGroup(systemCPUCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			sysCPUAvgIdleMD, | 
					
						
							|  |  |  | 			sysCPUAvgIOWaitMD, | 
					
						
							|  |  |  | 			sysCPULoadMD, | 
					
						
							|  |  |  | 			sysCPULoadPercMD, | 
					
						
							|  |  |  | 			sysCPUNiceMD, | 
					
						
							|  |  |  | 			sysCPUStealMD, | 
					
						
							|  |  |  | 			sysCPUSystemMD, | 
					
						
							|  |  |  | 			sysCPUUserMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadCPUMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-27 00:07:23 +08:00
										 |  |  | 	systemProcessMG := NewMetricsGroup(systemProcessCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			processLocksReadTotalMD, | 
					
						
							|  |  |  | 			processLocksWriteTotalMD, | 
					
						
							|  |  |  | 			processCPUTotalSecondsMD, | 
					
						
							|  |  |  | 			processGoRoutineTotalMD, | 
					
						
							|  |  |  | 			processIORCharBytesMD, | 
					
						
							|  |  |  | 			processIOReadBytesMD, | 
					
						
							|  |  |  | 			processIOWCharBytesMD, | 
					
						
							|  |  |  | 			processIOWriteBytesMD, | 
					
						
							|  |  |  | 			processStarttimeSecondsMD, | 
					
						
							|  |  |  | 			processUptimeSecondsMD, | 
					
						
							|  |  |  | 			processFileDescriptorLimitTotalMD, | 
					
						
							|  |  |  | 			processFileDescriptorOpenTotalMD, | 
					
						
							|  |  |  | 			processSyscallReadTotalMD, | 
					
						
							|  |  |  | 			processSyscallWriteTotalMD, | 
					
						
							|  |  |  | 			processResidentMemoryBytesMD, | 
					
						
							|  |  |  | 			processVirtualMemoryBytesMD, | 
					
						
							|  |  |  | 			processVirtualMemoryMaxBytesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadProcessMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	systemDriveMG := NewMetricsGroup(systemDriveCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			driveUsedBytesMD, | 
					
						
							|  |  |  | 			driveFreeBytesMD, | 
					
						
							|  |  |  | 			driveTotalBytesMD, | 
					
						
							| 
									
										
										
										
											2024-04-12 01:46:34 +08:00
										 |  |  | 			driveUsedInodesMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 			driveFreeInodesMD, | 
					
						
							| 
									
										
										
										
											2024-04-12 01:46:34 +08:00
										 |  |  | 			driveTotalInodesMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 			driveTimeoutErrorsMD, | 
					
						
							| 
									
										
										
										
											2024-04-26 06:01:31 +08:00
										 |  |  | 			driveIOErrorsMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 			driveAvailabilityErrorsMD, | 
					
						
							|  |  |  | 			driveWaitingIOMD, | 
					
						
							|  |  |  | 			driveAPILatencyMD, | 
					
						
							| 
									
										
										
										
											2024-05-13 01:23:50 +08:00
										 |  |  | 			driveHealthMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			driveOfflineCountMD, | 
					
						
							|  |  |  | 			driveOnlineCountMD, | 
					
						
							|  |  |  | 			driveCountMD, | 
					
						
							| 
									
										
										
										
											2024-04-12 01:46:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// iostat related
 | 
					
						
							|  |  |  | 			driveReadsPerSecMD, | 
					
						
							|  |  |  | 			driveReadsKBPerSecMD, | 
					
						
							|  |  |  | 			driveReadsAwaitMD, | 
					
						
							|  |  |  | 			driveWritesPerSecMD, | 
					
						
							|  |  |  | 			driveWritesKBPerSecMD, | 
					
						
							|  |  |  | 			driveWritesAwaitMD, | 
					
						
							|  |  |  | 			drivePercUtilMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		loadDriveMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	clusterHealthMG := NewMetricsGroup(clusterHealthCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			healthDrivesOfflineCountMD, | 
					
						
							|  |  |  | 			healthDrivesOnlineCountMD, | 
					
						
							|  |  |  | 			healthDrivesCountMD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			healthNodesOfflineCountMD, | 
					
						
							|  |  |  | 			healthNodesOnlineCountMD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			healthCapacityRawTotalBytesMD, | 
					
						
							|  |  |  | 			healthCapacityRawFreeBytesMD, | 
					
						
							|  |  |  | 			healthCapacityUsableTotalBytesMD, | 
					
						
							|  |  |  | 			healthCapacityUsableFreeBytesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		JoinLoaders(loadClusterHealthDriveMetrics, | 
					
						
							|  |  |  | 			loadClusterHealthNodeMetrics, | 
					
						
							|  |  |  | 			loadClusterHealthCapacityMetrics), | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	clusterUsageObjectsMG := NewMetricsGroup(clusterUsageObjectsCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			usageSinceLastUpdateSecondsMD, | 
					
						
							|  |  |  | 			usageTotalBytesMD, | 
					
						
							|  |  |  | 			usageObjectsCountMD, | 
					
						
							|  |  |  | 			usageVersionsCountMD, | 
					
						
							|  |  |  | 			usageDeleteMarkersCountMD, | 
					
						
							|  |  |  | 			usageBucketsCountMD, | 
					
						
							|  |  |  | 			usageObjectsDistributionMD, | 
					
						
							|  |  |  | 			usageVersionsDistributionMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterUsageObjectMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-15 02:11:42 +08:00
										 |  |  | 	clusterUsageBucketsMG := NewMetricsGroup(clusterUsageBucketsCollectorPath, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			usageSinceLastUpdateSecondsMD, | 
					
						
							|  |  |  | 			usageBucketTotalBytesMD, | 
					
						
							|  |  |  | 			usageBucketObjectsTotalMD, | 
					
						
							|  |  |  | 			usageBucketVersionsCountMD, | 
					
						
							|  |  |  | 			usageBucketDeleteMarkersCountMD, | 
					
						
							|  |  |  | 			usageBucketQuotaTotalBytesMD, | 
					
						
							|  |  |  | 			usageBucketObjectSizeDistributionMD, | 
					
						
							|  |  |  | 			usageBucketObjectVersionCountDistributionMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterUsageBucketMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	clusterErasureSetMG := NewMetricsGroup(clusterErasureSetCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			erasureSetOverallWriteQuorumMD, | 
					
						
							|  |  |  | 			erasureSetOverallHealthMD, | 
					
						
							|  |  |  | 			erasureSetReadQuorumMD, | 
					
						
							|  |  |  | 			erasureSetWriteQuorumMD, | 
					
						
							|  |  |  | 			erasureSetOnlineDrivesCountMD, | 
					
						
							|  |  |  | 			erasureSetHealingDrivesCountMD, | 
					
						
							|  |  |  | 			erasureSetHealthMD, | 
					
						
							| 
									
										
										
										
											2024-05-14 15:25:56 +08:00
										 |  |  | 			erasureSetReadToleranceMD, | 
					
						
							|  |  |  | 			erasureSetWriteToleranceMD, | 
					
						
							|  |  |  | 			erasureSetReadHealthMD, | 
					
						
							|  |  |  | 			erasureSetWriteHealthMD, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterErasureSetMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 19:10:24 +08:00
										 |  |  | 	clusterNotificationMG := NewMetricsGroup(notificationCollectorPath, | 
					
						
							| 
									
										
										
										
											2024-04-24 12:10:35 +08:00
										 |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			notificationCurrentSendInProgressMD, | 
					
						
							|  |  |  | 			notificationEventsErrorsTotalMD, | 
					
						
							|  |  |  | 			notificationEventsSentTotalMD, | 
					
						
							|  |  |  | 			notificationEventsSkippedTotalMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterNotificationMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 16:20:42 +08:00
										 |  |  | 	clusterIAMMG := NewMetricsGroup(clusterIAMCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			lastSyncDurationMillisMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceFailedRequestsMinuteMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceLastFailSecondsMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceLastSuccSecondsMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceSuccAvgRttMsMinuteMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceSuccMaxRttMsMinuteMD, | 
					
						
							|  |  |  | 			pluginAuthnServiceTotalRequestsMinuteMD, | 
					
						
							|  |  |  | 			sinceLastSyncMillisMD, | 
					
						
							|  |  |  | 			syncFailuresMD, | 
					
						
							|  |  |  | 			syncSuccessesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterIAMMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 	clusterReplicationMG := NewMetricsGroup(replicationCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			replicationAverageActiveWorkersMD, | 
					
						
							|  |  |  | 			replicationAverageQueuedBytesMD, | 
					
						
							|  |  |  | 			replicationAverageQueuedCountMD, | 
					
						
							|  |  |  | 			replicationAverageDataTransferRateMD, | 
					
						
							|  |  |  | 			replicationCurrentActiveWorkersMD, | 
					
						
							|  |  |  | 			replicationCurrentDataTransferRateMD, | 
					
						
							|  |  |  | 			replicationLastMinuteQueuedBytesMD, | 
					
						
							|  |  |  | 			replicationLastMinuteQueuedCountMD, | 
					
						
							|  |  |  | 			replicationMaxActiveWorkersMD, | 
					
						
							|  |  |  | 			replicationMaxQueuedBytesMD, | 
					
						
							|  |  |  | 			replicationMaxQueuedCountMD, | 
					
						
							|  |  |  | 			replicationMaxDataTransferRateMD, | 
					
						
							| 
									
										
										
										
											2024-08-02 08:55:27 +08:00
										 |  |  | 			replicationRecentBacklogCountMD, | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterReplicationMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 20:50:46 +08:00
										 |  |  | 	clusterConfigMG := NewMetricsGroup(clusterConfigCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			configRRSParityMD, | 
					
						
							|  |  |  | 			configStandardParityMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterConfigMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-25 03:29:25 +08:00
										 |  |  | 	scannerMG := NewMetricsGroup(scannerCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			scannerBucketScansFinishedMD, | 
					
						
							|  |  |  | 			scannerBucketScansStartedMD, | 
					
						
							|  |  |  | 			scannerDirectoriesScannedMD, | 
					
						
							|  |  |  | 			scannerObjectsScannedMD, | 
					
						
							|  |  |  | 			scannerVersionsScannedMD, | 
					
						
							|  |  |  | 			scannerLastActivitySecondsMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadClusterScannerMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-14 15:27:33 +08:00
										 |  |  | 	loggerWebhookMG := NewMetricsGroup(loggerWebhookCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			webhookFailedMessagesMD, | 
					
						
							|  |  |  | 			webhookQueueLengthMD, | 
					
						
							|  |  |  | 			webhookTotalMessagesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadLoggerWebhookMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-10 22:50:39 +08:00
										 |  |  | 	auditMG := NewMetricsGroup(auditCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			auditFailedMessagesMD, | 
					
						
							|  |  |  | 			auditTargetQueueLengthMD, | 
					
						
							|  |  |  | 			auditTotalMessagesMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadAuditMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-06 17:36:25 +08:00
										 |  |  | 	ilmMG := NewMetricsGroup(ilmCollectorPath, | 
					
						
							|  |  |  | 		[]MetricDescriptor{ | 
					
						
							|  |  |  | 			ilmExpiryPendingTasksMD, | 
					
						
							|  |  |  | 			ilmTransitionActiveTasksMD, | 
					
						
							|  |  |  | 			ilmTransitionPendingTasksMD, | 
					
						
							|  |  |  | 			ilmTransitionMissedImmediateTasksMD, | 
					
						
							|  |  |  | 			ilmVersionsScannedMD, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		loadILMMetrics, | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	allMetricGroups := []*MetricsGroup{ | 
					
						
							|  |  |  | 		apiRequestsMG, | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 		bucketAPIMG, | 
					
						
							|  |  |  | 		bucketReplicationMG, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		systemNetworkInternodeMG, | 
					
						
							|  |  |  | 		systemDriveMG, | 
					
						
							| 
									
										
										
										
											2024-04-17 13:10:25 +08:00
										 |  |  | 		systemMemoryMG, | 
					
						
							| 
									
										
										
										
											2024-04-24 07:56:12 +08:00
										 |  |  | 		systemCPUMG, | 
					
						
							| 
									
										
										
										
											2024-04-27 00:07:23 +08:00
										 |  |  | 		systemProcessMG, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		clusterHealthMG, | 
					
						
							|  |  |  | 		clusterUsageObjectsMG, | 
					
						
							|  |  |  | 		clusterUsageBucketsMG, | 
					
						
							|  |  |  | 		clusterErasureSetMG, | 
					
						
							| 
									
										
										
										
											2024-04-24 12:10:35 +08:00
										 |  |  | 		clusterNotificationMG, | 
					
						
							| 
									
										
										
										
											2024-05-02 16:20:42 +08:00
										 |  |  | 		clusterIAMMG, | 
					
						
							| 
									
										
										
										
											2024-05-23 15:41:18 +08:00
										 |  |  | 		clusterReplicationMG, | 
					
						
							| 
									
										
										
										
											2024-05-24 20:50:46 +08:00
										 |  |  | 		clusterConfigMG, | 
					
						
							| 
									
										
										
										
											2024-05-10 22:50:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-06 17:36:25 +08:00
										 |  |  | 		ilmMG, | 
					
						
							| 
									
										
										
										
											2024-05-25 03:29:25 +08:00
										 |  |  | 		scannerMG, | 
					
						
							| 
									
										
										
										
											2024-05-10 22:50:39 +08:00
										 |  |  | 		auditMG, | 
					
						
							| 
									
										
										
										
											2024-05-14 15:27:33 +08:00
										 |  |  | 		loggerWebhookMG, | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Bucket metrics are special, they always include the bucket label. These
 | 
					
						
							|  |  |  | 	// metrics required a list of buckets to be passed to the loader, and the list
 | 
					
						
							|  |  |  | 	// of buckets is not known until the request is made. So we keep a separate
 | 
					
						
							|  |  |  | 	// map for bucket metrics and handle them specially.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Add the serverName and poolIndex labels to all non-cluster metrics.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Also create metric group maps and set the cache.
 | 
					
						
							|  |  |  | 	metricsCache := newMetricsCache() | 
					
						
							|  |  |  | 	mgMap := make(map[collectorPath]*MetricsGroup) | 
					
						
							|  |  |  | 	bucketMGMap := make(map[collectorPath]*MetricsGroup) | 
					
						
							|  |  |  | 	for _, mg := range allMetricGroups { | 
					
						
							|  |  |  | 		if !strings.HasPrefix(string(mg.CollectorPath), clusterBasePath) { | 
					
						
							|  |  |  | 			mg.AddExtraLabels( | 
					
						
							|  |  |  | 				serverName, globalLocalNodeName, | 
					
						
							|  |  |  | 				// poolIndex, strconv.Itoa(globalLocalPoolIdx),
 | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		mg.SetCache(metricsCache) | 
					
						
							|  |  |  | 		if mg.IsBucketMetricsGroup() { | 
					
						
							|  |  |  | 			bucketMGMap[mg.CollectorPath] = mg | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			mgMap[mg.CollectorPath] = mg | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Prepare to register the collectors. Other than `MetricGroup` collectors,
 | 
					
						
							| 
									
										
										
										
											2024-04-27 00:07:23 +08:00
										 |  |  | 	// we also have standard collectors like `GoCollector`.
 | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Create all Non-`MetricGroup` collectors here.
 | 
					
						
							|  |  |  | 	collectors := map[collectorPath]prometheus.Collector{ | 
					
						
							| 
									
										
										
										
											2024-05-14 15:25:37 +08:00
										 |  |  | 		debugGoCollectorPath: collectors.NewGoCollector(), | 
					
						
							| 
									
										
										
										
											2024-03-10 17:15:15 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Add all `MetricGroup` collectors to the map.
 | 
					
						
							|  |  |  | 	for _, mg := range allMetricGroups { | 
					
						
							|  |  |  | 		collectors[mg.CollectorPath] = mg | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Helper function to register a collector and return a gatherer for it.
 | 
					
						
							|  |  |  | 	mustRegister := func(c ...prometheus.Collector) prometheus.Gatherer { | 
					
						
							|  |  |  | 		subRegistry := prometheus.NewRegistry() | 
					
						
							|  |  |  | 		for _, col := range c { | 
					
						
							|  |  |  | 			subRegistry.MustRegister(col) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		r.MustRegister(subRegistry) | 
					
						
							|  |  |  | 		return subRegistry | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Register all collectors and create gatherers for them.
 | 
					
						
							|  |  |  | 	gatherers := make(map[collectorPath]prometheus.Gatherer, len(collectors)) | 
					
						
							|  |  |  | 	collectorPaths := make([]collectorPath, 0, len(collectors)) | 
					
						
							|  |  |  | 	for path, collector := range collectors { | 
					
						
							|  |  |  | 		gatherers[path] = mustRegister(collector) | 
					
						
							|  |  |  | 		collectorPaths = append(collectorPaths, path) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	slices.Sort(collectorPaths) | 
					
						
							|  |  |  | 	return &metricsV3Collection{ | 
					
						
							|  |  |  | 		mgMap:          mgMap, | 
					
						
							|  |  |  | 		bucketMGMap:    bucketMGMap, | 
					
						
							|  |  |  | 		mgGatherers:    gatherers, | 
					
						
							|  |  |  | 		collectorPaths: collectorPaths, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |