2021-09-18 16:31:35 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2021-10-23 21:38:33 -04:00
|
|
|
"sort"
|
2021-09-18 16:31:35 -04:00
|
|
|
"time"
|
2021-10-23 21:38:33 -04:00
|
|
|
|
2023-06-19 20:53:08 -04:00
|
|
|
"github.com/minio/madmin-go/v3"
|
2021-09-18 16:31:35 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// BucketTargetUsageInfo - bucket target usage info provides
|
|
|
|
// - replicated size for all objects sent to this target
|
|
|
|
// - replica size for all objects received from this target
|
|
|
|
// - replication pending size for all objects pending replication to this target
|
|
|
|
// - replication failed size for all objects failed replication to this target
|
|
|
|
// - replica pending count
|
|
|
|
// - replica failed count
|
|
|
|
type BucketTargetUsageInfo struct {
|
|
|
|
ReplicationPendingSize uint64 `json:"objectsPendingReplicationTotalSize"`
|
|
|
|
ReplicationFailedSize uint64 `json:"objectsFailedReplicationTotalSize"`
|
|
|
|
ReplicatedSize uint64 `json:"objectsReplicatedTotalSize"`
|
|
|
|
ReplicaSize uint64 `json:"objectReplicaTotalSize"`
|
|
|
|
ReplicationPendingCount uint64 `json:"objectsPendingReplicationCount"`
|
|
|
|
ReplicationFailedCount uint64 `json:"objectsFailedReplicationCount"`
|
2023-08-30 04:00:59 -04:00
|
|
|
ReplicatedCount uint64 `json:"objectsReplicatedCount"`
|
2021-09-18 16:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// BucketUsageInfo - bucket usage info provides
|
|
|
|
// - total size of the bucket
|
|
|
|
// - total objects in a bucket
|
|
|
|
// - object size histogram per bucket
|
|
|
|
type BucketUsageInfo struct {
|
|
|
|
Size uint64 `json:"size"`
|
|
|
|
// Following five fields suffixed with V1 are here for backward compatibility
|
|
|
|
// Total Size for objects that have not yet been replicated
|
|
|
|
ReplicationPendingSizeV1 uint64 `json:"objectsPendingReplicationTotalSize"`
|
|
|
|
// Total size for objects that have witness one or more failures and will be retried
|
|
|
|
ReplicationFailedSizeV1 uint64 `json:"objectsFailedReplicationTotalSize"`
|
|
|
|
// Total size for objects that have been replicated to destination
|
|
|
|
ReplicatedSizeV1 uint64 `json:"objectsReplicatedTotalSize"`
|
|
|
|
// Total number of objects pending replication
|
|
|
|
ReplicationPendingCountV1 uint64 `json:"objectsPendingReplicationCount"`
|
|
|
|
// Total number of objects that failed replication
|
|
|
|
ReplicationFailedCountV1 uint64 `json:"objectsFailedReplicationCount"`
|
|
|
|
|
2023-03-10 11:53:59 -05:00
|
|
|
ObjectsCount uint64 `json:"objectsCount"`
|
|
|
|
ObjectSizesHistogram map[string]uint64 `json:"objectsSizesHistogram"`
|
|
|
|
ObjectVersionsHistogram map[string]uint64 `json:"objectsVersionsHistogram"`
|
|
|
|
VersionsCount uint64 `json:"versionsCount"`
|
2023-07-18 13:49:40 -04:00
|
|
|
DeleteMarkersCount uint64 `json:"deleteMarkersCount"`
|
2023-03-10 11:53:59 -05:00
|
|
|
ReplicaSize uint64 `json:"objectReplicaTotalSize"`
|
2023-08-30 04:00:59 -04:00
|
|
|
ReplicaCount uint64 `json:"objectReplicaCount"`
|
2023-03-10 11:53:59 -05:00
|
|
|
ReplicationInfo map[string]BucketTargetUsageInfo `json:"objectsReplicationInfo"`
|
2021-09-18 16:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// DataUsageInfo represents data usage stats of the underlying Object API
|
|
|
|
type DataUsageInfo struct {
|
2024-01-30 20:49:37 -05:00
|
|
|
TotalCapacity uint64 `json:"capacity,omitempty"`
|
|
|
|
TotalUsedCapacity uint64 `json:"usedCapacity,omitempty"`
|
|
|
|
TotalFreeCapacity uint64 `json:"freeCapacity,omitempty"`
|
|
|
|
|
2021-09-18 16:31:35 -04:00
|
|
|
// LastUpdate is the timestamp of when the data usage info was last updated.
|
|
|
|
// This does not indicate a full scan.
|
|
|
|
LastUpdate time.Time `json:"lastUpdate"`
|
|
|
|
|
|
|
|
// Objects total count across all buckets
|
|
|
|
ObjectsTotalCount uint64 `json:"objectsCount"`
|
|
|
|
|
2023-07-18 13:49:40 -04:00
|
|
|
// Versions total count across all buckets
|
2022-04-26 01:04:10 -04:00
|
|
|
VersionsTotalCount uint64 `json:"versionsCount"`
|
|
|
|
|
2023-07-18 13:49:40 -04:00
|
|
|
// Delete markers total count across all buckets
|
|
|
|
DeleteMarkersTotalCount uint64 `json:"deleteMarkersCount"`
|
|
|
|
|
2021-09-18 16:31:35 -04:00
|
|
|
// Objects total size across all buckets
|
|
|
|
ObjectsTotalSize uint64 `json:"objectsTotalSize"`
|
|
|
|
ReplicationInfo map[string]BucketTargetUsageInfo `json:"objectsReplicationInfo"`
|
2024-01-30 20:49:37 -05:00
|
|
|
|
2021-09-18 16:31:35 -04:00
|
|
|
// Total number of buckets in this cluster
|
|
|
|
BucketsCount uint64 `json:"bucketsCount"`
|
|
|
|
|
|
|
|
// Buckets usage info provides following information across all buckets
|
|
|
|
// - total size of the bucket
|
|
|
|
// - total objects in a bucket
|
|
|
|
// - object size histogram per bucket
|
|
|
|
BucketsUsage map[string]BucketUsageInfo `json:"bucketsUsageInfo"`
|
|
|
|
// Deprecated kept here for backward compatibility reasons.
|
|
|
|
BucketSizes map[string]uint64 `json:"bucketsSizes"`
|
2021-10-23 21:38:33 -04:00
|
|
|
|
|
|
|
// TierStats contains per-tier stats of all configured remote tiers
|
|
|
|
TierStats *allTierStats `json:"tierStats,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dui DataUsageInfo) tierStats() []madmin.TierInfo {
|
2022-03-08 15:08:29 -05:00
|
|
|
if dui.TierStats == nil {
|
2021-10-23 21:38:33 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-10-30 12:59:51 -04:00
|
|
|
if globalTierConfigMgr.Empty() {
|
2022-03-08 15:08:29 -05:00
|
|
|
return nil
|
2021-10-23 21:38:33 -04:00
|
|
|
}
|
|
|
|
|
2023-10-30 12:59:51 -04:00
|
|
|
ts := make(map[string]madmin.TierStats)
|
|
|
|
dui.TierStats.populateStats(ts)
|
2022-03-08 15:08:29 -05:00
|
|
|
|
2023-10-30 12:59:51 -04:00
|
|
|
infos := make([]madmin.TierInfo, 0, len(ts))
|
|
|
|
for tier, stats := range ts {
|
2021-10-23 21:38:33 -04:00
|
|
|
infos = append(infos, madmin.TierInfo{
|
2023-10-30 12:59:51 -04:00
|
|
|
Name: tier,
|
|
|
|
Type: globalTierConfigMgr.TierType(tier),
|
|
|
|
Stats: stats,
|
2021-10-23 21:38:33 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(infos, func(i, j int) bool {
|
|
|
|
if infos[i].Type == "internal" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if infos[j].Type == "internal" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return infos[i].Name < infos[j].Name
|
|
|
|
})
|
|
|
|
return infos
|
2021-09-18 16:31:35 -04:00
|
|
|
}
|
2022-03-08 15:08:29 -05:00
|
|
|
|
2024-03-10 05:15:15 -04:00
|
|
|
func (dui DataUsageInfo) tierMetrics() (metrics []MetricV2) {
|
2022-03-08 15:08:29 -05:00
|
|
|
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 {
|
2024-03-10 05:15:15 -04:00
|
|
|
metrics = append(metrics, MetricV2{
|
2022-03-08 15:08:29 -05:00
|
|
|
Description: getClusterTransitionedBytesMD(),
|
|
|
|
Value: float64(st.TotalSize),
|
|
|
|
VariableLabels: map[string]string{"tier": tier},
|
|
|
|
})
|
2024-03-10 05:15:15 -04:00
|
|
|
metrics = append(metrics, MetricV2{
|
2022-03-08 15:08:29 -05:00
|
|
|
Description: getClusterTransitionedObjectsMD(),
|
|
|
|
Value: float64(st.NumObjects),
|
|
|
|
VariableLabels: map[string]string{"tier": tier},
|
|
|
|
})
|
2024-03-10 05:15:15 -04:00
|
|
|
metrics = append(metrics, MetricV2{
|
2022-03-08 15:08:29 -05:00
|
|
|
Description: getClusterTransitionedVersionsMD(),
|
|
|
|
Value: float64(st.NumVersions),
|
|
|
|
VariableLabels: map[string]string{"tier": tier},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return metrics
|
|
|
|
}
|