mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Simplify assembling of tierStats from data-usage (#14504)
This commit is contained in:
parent
4d0715d226
commit
80ef1ae51c
@ -92,32 +92,37 @@ type DataUsageInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dui DataUsageInfo) tierStats() []madmin.TierInfo {
|
func (dui DataUsageInfo) tierStats() []madmin.TierInfo {
|
||||||
if globalTierConfigMgr.Empty() {
|
if dui.TierStats == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := make(map[string]madmin.TierStats)
|
cfgs := globalTierConfigMgr.ListTiers()
|
||||||
// Add configured remote tiers
|
if len(cfgs) == 0 {
|
||||||
for tier := range globalTierConfigMgr.Tiers {
|
return nil
|
||||||
ts[tier] = madmin.TierStats{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ts := make(map[string]madmin.TierStats, len(cfgs)+1)
|
||||||
|
infos := make([]madmin.TierInfo, 0, len(ts))
|
||||||
|
|
||||||
// Add STANDARD (hot-tier)
|
// Add STANDARD (hot-tier)
|
||||||
ts[minioHotTier] = madmin.TierStats{}
|
ts[minioHotTier] = madmin.TierStats{}
|
||||||
|
infos = append(infos, madmin.TierInfo{
|
||||||
|
Name: minioHotTier,
|
||||||
|
Type: "internal",
|
||||||
|
})
|
||||||
|
// Add configured remote tiers
|
||||||
|
for _, cfg := range cfgs {
|
||||||
|
ts[cfg.Name] = madmin.TierStats{}
|
||||||
|
infos = append(infos, madmin.TierInfo{
|
||||||
|
Name: cfg.Name,
|
||||||
|
Type: cfg.Type.String(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
ts = dui.TierStats.adminStats(ts)
|
ts = dui.TierStats.adminStats(ts)
|
||||||
infos := make([]madmin.TierInfo, 0, len(ts))
|
for i := range infos {
|
||||||
for tier, st := range ts {
|
info := infos[i]
|
||||||
var tierType string
|
infos[i].Stats = ts[info.Name]
|
||||||
if tier == minioHotTier {
|
|
||||||
tierType = "internal"
|
|
||||||
} else {
|
|
||||||
tierType = globalTierConfigMgr.Tiers[tier].Type.String()
|
|
||||||
}
|
|
||||||
infos = append(infos, madmin.TierInfo{
|
|
||||||
Name: tier,
|
|
||||||
Type: tierType,
|
|
||||||
Stats: st,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(infos, func(i, j int) bool {
|
sort.Slice(infos, func(i, j int) bool {
|
||||||
@ -131,3 +136,31 @@ func (dui DataUsageInfo) tierStats() []madmin.TierInfo {
|
|||||||
})
|
})
|
||||||
return infos
|
return infos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dui DataUsageInfo) tierMetrics() (metrics []Metric) {
|
||||||
|
if dui.TierStats == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// e.g minio_cluster_ilm_transitioned_bytes{tier="S3TIER-1"}=136314880
|
||||||
|
// minio_cluster_ilm_transitioned_objects{tier="S3TIER-1"}=1
|
||||||
|
// minio_cluster_ilm_transitioned_versions{tier="S3TIER-1"}=3
|
||||||
|
for tier, st := range dui.TierStats.Tiers {
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getClusterTransitionedBytesMD(),
|
||||||
|
Value: float64(st.TotalSize),
|
||||||
|
VariableLabels: map[string]string{"tier": tier},
|
||||||
|
})
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getClusterTransitionedObjectsMD(),
|
||||||
|
Value: float64(st.NumObjects),
|
||||||
|
VariableLabels: map[string]string{"tier": tier},
|
||||||
|
})
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: getClusterTransitionedVersionsMD(),
|
||||||
|
Value: float64(st.NumVersions),
|
||||||
|
VariableLabels: map[string]string{"tier": tier},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return metrics
|
||||||
|
}
|
||||||
|
@ -1668,28 +1668,7 @@ func getClusterTierMetrics() *MetricsGroup {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// e.g minio_cluster_ilm_transitioned_bytes{tier="S3TIER-1"}=136314880
|
return dui.tierMetrics()
|
||||||
// minio_cluster_ilm_transitioned_objects{tier="S3TIER-1"}=1
|
|
||||||
// minio_cluster_ilm_transitioned_versions{tier="S3TIER-1"}=3
|
|
||||||
for tier, st := range dui.TierStats.Tiers {
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getClusterTransitionedBytesMD(),
|
|
||||||
Value: float64(st.TotalSize),
|
|
||||||
VariableLabels: map[string]string{"tier": tier},
|
|
||||||
})
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getClusterTransitionedObjectsMD(),
|
|
||||||
Value: float64(st.NumObjects),
|
|
||||||
VariableLabels: map[string]string{"tier": tier},
|
|
||||||
})
|
|
||||||
metrics = append(metrics, Metric{
|
|
||||||
Description: getClusterTransitionedVersionsMD(),
|
|
||||||
Value: float64(st.NumVersions),
|
|
||||||
VariableLabels: map[string]string{"tier": tier},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return metrics
|
|
||||||
})
|
})
|
||||||
return mg
|
return mg
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user