fix: export prometheus metrics for cache GC triggers (#9815)

Bonus change to use channel to serialize triggers,
instead of using atomic variables. More efficient
mechanism for synchronization.
This commit is contained in:
Harshavardhana
2020-06-15 09:05:35 -07:00
parent a1e6a3ef64
commit 49c8d36497
7 changed files with 134 additions and 60 deletions
+21
View File
@@ -260,6 +260,27 @@ func cacheMetricsPrometheus(ch chan<- prometheus.Metric) {
prometheus.CounterValue,
float64(cacheObjLayer.CacheStats().getBytesServed()),
)
for _, cdStats := range cacheObjLayer.CacheStats().GetDiskStats() {
// Cache disk usage percentage
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName("cache", "usage", "percent"),
"Total percentage cache usage",
[]string{"disk"}, nil),
prometheus.GaugeValue,
float64(cdStats.UsagePercent),
cdStats.Dir,
)
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName("cache", "usage", "high"),
"Indicates cache usage is high or low, relative to current cache 'quota' settings",
[]string{"disk"}, nil),
prometheus.GaugeValue,
float64(cdStats.UsageState),
cdStats.Dir,
)
}
}
// collects http metrics for MinIO server in Prometheus specific format