From ecc154fa9e9bd11f2a664d2d11bd15c76d8b6c49 Mon Sep 17 00:00:00 2001 From: Seyed Mahdi Sadegh Shobeiri <36403983+SmsS4@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:58:46 +0330 Subject: [PATCH] Add deleted bytes to total_disk_size (#5161) --- weed/storage/store.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/storage/store.go b/weed/storage/store.go index d290909f1..782eb5b79 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -251,6 +251,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { maxVolumeCounts := make(map[string]uint32) var maxFileKey NeedleId collectionVolumeSize := make(map[string]int64) + collectionVolumeDeletedBytes := make(map[string]int64) collectionVolumeReadOnlyCount := make(map[string]map[string]uint8) for _, location := range s.Locations { var deleteVids []needle.VolumeId @@ -283,9 +284,11 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { if _, exist := collectionVolumeSize[v.Collection]; !exist { collectionVolumeSize[v.Collection] = 0 + collectionVolumeDeletedBytes[v.Collection] = 0 } if !shouldDeleteVolume { collectionVolumeSize[v.Collection] += int64(volumeMessage.Size) + collectionVolumeDeletedBytes[v.Collection] += int64(volumeMessage.DeletedByteCount) } else { collectionVolumeSize[v.Collection] -= int64(volumeMessage.Size) if collectionVolumeSize[v.Collection] <= 0 { @@ -342,6 +345,10 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "normal").Set(float64(size)) } + for col, deletedBytes := range collectionVolumeDeletedBytes{ + stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "deleted_bytes").Set(float64(deletedBytes)) + } + for col, types := range collectionVolumeReadOnlyCount { for t, count := range types { stats.VolumeServerReadOnlyVolumeGauge.WithLabelValues(col, t).Set(float64(count))