fix: disk usage capacity metric reporting (#11435)

master
Ritesh H Shukla 4 years ago committed by GitHub
parent 075c429021
commit 67a8f37df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      cmd/metrics-v2.go
  2. 8
      cmd/metrics.go
  3. 25
      cmd/notification-summary.go

@ -387,7 +387,7 @@ func getS3RequestsInFlightMD() MetricDescription {
Subsystem: requestsSubsystem, Subsystem: requestsSubsystem,
Name: inflightTotal, Name: inflightTotal,
Help: "Total number of S3 requests currently in flight.", Help: "Total number of S3 requests currently in flight.",
Type: counterMetric, Type: gaugeMetric,
} }
} }
func getS3RequestsTotalMD() MetricDescription { func getS3RequestsTotalMD() MetricDescription {
@ -1106,23 +1106,23 @@ func getClusterStorageMetrics() MetricsGroup {
metrics.Metrics = append(metrics.Metrics, Metric{ metrics.Metrics = append(metrics.Metrics, Metric{
Description: getClusterCapacityTotalBytesMD(), Description: getClusterCapacityTotalBytesMD(),
Value: float64(GetTotalCapacity(ctx)), Value: float64(GetTotalCapacity(storageInfo.Disks)),
}) })
metrics.Metrics = append(metrics.Metrics, Metric{ metrics.Metrics = append(metrics.Metrics, Metric{
Description: getClusterCapacityFreeBytesMD(), Description: getClusterCapacityFreeBytesMD(),
Value: float64(GetTotalCapacityFree(ctx)), Value: float64(GetTotalCapacityFree(storageInfo.Disks)),
}) })
s, _ := objLayer.StorageInfo(GlobalContext) s, _ := objLayer.StorageInfo(GlobalContext)
metrics.Metrics = append(metrics.Metrics, Metric{ metrics.Metrics = append(metrics.Metrics, Metric{
Description: getClusterCapacityUsageBytesMD(), Description: getClusterCapacityUsageBytesMD(),
Value: GetTotalUsableCapacity(ctx, s), Value: GetTotalUsableCapacity(storageInfo.Disks, s),
}) })
metrics.Metrics = append(metrics.Metrics, Metric{ metrics.Metrics = append(metrics.Metrics, Metric{
Description: getClusterCapacityUsageFreeBytesMD(), Description: getClusterCapacityUsageFreeBytesMD(),
Value: GetTotalUsableCapacityFree(ctx, s), Value: GetTotalUsableCapacityFree(storageInfo.Disks, s),
}) })
metrics.Metrics = append(metrics.Metrics, Metric{ metrics.Metrics = append(metrics.Metrics, Metric{

@ -535,7 +535,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total capacity online in the cluster", "Total capacity online in the cluster",
nil, nil), nil, nil),
prometheus.GaugeValue, prometheus.GaugeValue,
float64(GetTotalCapacity(GlobalContext)), float64(GetTotalCapacity(server.Disks)),
) )
// Report total capacity free // Report total capacity free
@ -545,7 +545,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total free capacity online in the cluster", "Total free capacity online in the cluster",
nil, nil), nil, nil),
prometheus.GaugeValue, prometheus.GaugeValue,
float64(GetTotalCapacityFree(GlobalContext)), float64(GetTotalCapacityFree(server.Disks)),
) )
s, _ := objLayer.StorageInfo(GlobalContext) s, _ := objLayer.StorageInfo(GlobalContext)
@ -556,7 +556,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total usable capacity online in the cluster", "Total usable capacity online in the cluster",
nil, nil), nil, nil),
prometheus.GaugeValue, prometheus.GaugeValue,
GetTotalUsableCapacity(GlobalContext, s), GetTotalUsableCapacity(server.Disks, s),
) )
// Report total usable capacity free // Report total usable capacity free
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
@ -565,7 +565,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total free usable capacity online in the cluster", "Total free usable capacity online in the cluster",
nil, nil), nil, nil),
prometheus.GaugeValue, prometheus.GaugeValue,
GetTotalUsableCapacityFree(GlobalContext, s), GetTotalUsableCapacityFree(server.Disks, s),
) )
// MinIO Offline Disks per node // MinIO Offline Disks per node

@ -18,22 +18,22 @@
package cmd package cmd
import ( import (
"context" "github.com/minio/minio/pkg/madmin"
) )
// GetTotalCapacity gets the total capacity in the cluster. // GetTotalCapacity gets the total capacity in the cluster.
func GetTotalCapacity(ctx context.Context) (capacity uint64) { func GetTotalCapacity(diskInfo []madmin.Disk) (capacity uint64) {
d := globalNotificationSys.DiskHwInfo(ctx)
for _, s := range d { for _, disk := range diskInfo {
capacity += s.GetTotalCapacity() capacity += disk.TotalSpace
} }
return return
} }
// GetTotalUsableCapacity gets the total usable capacity in the cluster. // GetTotalUsableCapacity gets the total usable capacity in the cluster.
// This value is not an accurate representation of total usable in a multi-tenant deployment. // This value is not an accurate representation of total usable in a multi-tenant deployment.
func GetTotalUsableCapacity(ctx context.Context, s StorageInfo) (capacity float64) { func GetTotalUsableCapacity(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
raw := GetTotalCapacity(ctx) raw := GetTotalCapacity(diskInfo)
var approxDataBlocks float64 var approxDataBlocks float64
var actualDisks float64 var actualDisks float64
for _, scData := range s.Backend.StandardSCData { for _, scData := range s.Backend.StandardSCData {
@ -45,18 +45,17 @@ func GetTotalUsableCapacity(ctx context.Context, s StorageInfo) (capacity float6
} }
// GetTotalCapacityFree gets the total capacity free in the cluster. // GetTotalCapacityFree gets the total capacity free in the cluster.
func GetTotalCapacityFree(ctx context.Context) (capacity uint64) { func GetTotalCapacityFree(diskInfo []madmin.Disk) (capacity uint64) {
d := globalNotificationSys.DiskHwInfo(ctx) for _, d := range diskInfo {
for _, s := range d { capacity += d.AvailableSpace
capacity += s.GetTotalFreeCapacity()
} }
return return
} }
// GetTotalUsableCapacityFree gets the total usable capacity free in the cluster. // GetTotalUsableCapacityFree gets the total usable capacity free in the cluster.
// This value is not an accurate representation of total free in a multi-tenant deployment. // This value is not an accurate representation of total free in a multi-tenant deployment.
func GetTotalUsableCapacityFree(ctx context.Context, s StorageInfo) (capacity float64) { func GetTotalUsableCapacityFree(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
raw := GetTotalCapacityFree(ctx) raw := GetTotalCapacityFree(diskInfo)
var approxDataBlocks float64 var approxDataBlocks float64
var actualDisks float64 var actualDisks float64
for _, scData := range s.Backend.StandardSCData { for _, scData := range s.Backend.StandardSCData {

Loading…
Cancel
Save