Add node cpu & memory metrics to Prometheus cluster endpoint (#12214)

This commit is contained in:
Nitish Tiwari 2021-05-04 22:47:10 +05:30 committed by GitHub
parent ff36baeaa7
commit c8aa56ccd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

View File

@ -120,6 +120,8 @@ const (
lastActivityTime = "last_activity_nano_seconds"
startTime = "starttime_seconds"
upTime = "uptime_seconds"
memory = "resident_memory_bytes"
cpu = "cpu_total_seconds"
)
const (
@ -821,6 +823,24 @@ func getMinIOProcessUptimeMD() MetricDescription {
Type: gaugeMetric,
}
}
func getMinIOProcessResidentMemory() MetricDescription {
return MetricDescription{
Namespace: nodeMetricNamespace,
Subsystem: processSubsystem,
Name: memory,
Help: "Resident memory size in bytes.",
Type: gaugeMetric,
}
}
func getMinIOProcessCPUTime() MetricDescription {
return MetricDescription{
Namespace: nodeMetricNamespace,
Subsystem: processSubsystem,
Name: cpu,
Help: "Total user and system CPU time spent in seconds.",
Type: counterMetric,
}
}
func getMinioProcMetrics() MetricsGroup {
return MetricsGroup{
id: "MinioProcMetrics",
@ -913,6 +933,16 @@ func getMinioProcMetrics() MetricsGroup {
Description: getMinIOProcessUptimeMD(),
Value: time.Since(globalBootTime).Seconds(),
})
metrics = append(metrics,
Metric{
Description: getMinIOProcessResidentMemory(),
Value: float64(stat.ResidentMemory()),
})
metrics = append(metrics,
Metric{
Description: getMinIOProcessCPUTime(),
Value: float64(stat.CPUTime()),
})
return
},
}