Add system CPU metrics to metrics-v3 (#19560)

endpoint: /minio/metrics/v3/system/cpu

metrics:
- minio_system_cpu_avg_idle
- minio_system_cpu_avg_iowait
- minio_system_cpu_load
- minio_system_cpu_load_perc
- minio_system_cpu_nice
- minio_system_cpu_steal
- minio_system_cpu_system
- minio_system_cpu_user
This commit is contained in:
Shireesh Anjal
2024-04-24 05:26:12 +05:30
committed by GitHub
parent 9693c382a8
commit f7b665347e
5 changed files with 150 additions and 9 deletions

View File

@@ -162,14 +162,7 @@ func init() {
resourceCollector = newMinioResourceCollector(resourceMetricsGroups)
}
func updateResourceMetrics(subSys MetricSubsystem, name MetricName, val float64, labels map[string]string, isCumulative bool) {
resourceMetricsMapMu.Lock()
defer resourceMetricsMapMu.Unlock()
subsysMetrics, found := resourceMetricsMap[subSys]
if !found {
subsysMetrics = ResourceMetrics{}
}
func getResourceKey(name MetricName, labels map[string]string) string {
// labels are used to uniquely identify a metric
// e.g. reads_per_sec_{drive} inside the map
sfx := ""
@@ -180,7 +173,18 @@ func updateResourceMetrics(subSys MetricSubsystem, name MetricName, val float64,
sfx += v
}
key := string(name) + "_" + sfx
return string(name) + "_" + sfx
}
func updateResourceMetrics(subSys MetricSubsystem, name MetricName, val float64, labels map[string]string, isCumulative bool) {
resourceMetricsMapMu.Lock()
defer resourceMetricsMapMu.Unlock()
subsysMetrics, found := resourceMetricsMap[subSys]
if !found {
subsysMetrics = ResourceMetrics{}
}
key := getResourceKey(name, labels)
metric, found := subsysMetrics[key]
if !found {
metric = ResourceMetric{