diff --git a/docs/user_guide/metrics.md b/docs/user_guide/metrics.md index 33eb20f07..d9a9f99eb 100644 --- a/docs/user_guide/metrics.md +++ b/docs/user_guide/metrics.md @@ -26,6 +26,8 @@ dragonfly_supernode_cdn_download_failed_total | dragonfly_supernode_pieces_downloaded_size_bytes_total | | counter | Total size of pieces downloaded from supernode in bytes. dragonfly_supernode_gc_peers_total | | counter | Total number of peers that have been garbage collected. dragonfly_supernode_gc_tasks_total | | counter | Total number of tasks that have been garbage collected. +dragonfly_supernode_gc_disks_total | | counter | Total number of garbage collecting the task data in disks. +dragonfly_supernode_last_gc_disks_timestamp_seconds | | gauge | Timestamp of the last disk gc. ## Dfdaemon diff --git a/supernode/config/config.go b/supernode/config/config.go index 0dbc5697e..7a9a74185 100644 --- a/supernode/config/config.go +++ b/supernode/config/config.go @@ -237,8 +237,8 @@ type BaseProperties struct { // IntervalThreshold is the threshold of the interval at which the task file is accessed. IntervalThreshold time.Duration `yaml:"IntervalThreshold"` - // CleanRatio the ratio to clean the disk and based on 10. - // And the value of CleanRatio should be [1-10]. + // CleanRatio is the ratio to clean the disk and it is based on 10. + // It means the value of CleanRatio should be [1-10]. // // default: 1 CleanRatio int diff --git a/supernode/daemon/mgr/gc/gc_disk.go b/supernode/daemon/mgr/gc/gc_disk.go index 19d29797d..43907c078 100644 --- a/supernode/daemon/mgr/gc/gc_disk.go +++ b/supernode/daemon/mgr/gc/gc_disk.go @@ -69,6 +69,8 @@ func (gcm *Manager) deleteTaskDisk(ctx context.Context, gcTaskIDs []string) { util.ReleaseLock(taskID, false) count++ } + gcm.metrics.gcDisksCount.WithLabelValues().Add(float64(count)) + gcm.metrics.lastGCDisksTime.WithLabelValues().SetToCurrentTime() logrus.Debugf("gc disk: success to gc task count(%d), remainder count(%d)", count, len(gcTaskIDs)-count) } diff --git a/supernode/daemon/mgr/gc/gc_manager.go b/supernode/daemon/mgr/gc/gc_manager.go index 27b787ad2..414fbbccd 100644 --- a/supernode/daemon/mgr/gc/gc_manager.go +++ b/supernode/daemon/mgr/gc/gc_manager.go @@ -31,16 +31,25 @@ import ( var _ mgr.GCMgr = &Manager{} type metrics struct { - gcTasksCount *prometheus.CounterVec - gcPeersCount *prometheus.CounterVec + gcTasksCount *prometheus.CounterVec + gcPeersCount *prometheus.CounterVec + gcDisksCount *prometheus.CounterVec + lastGCDisksTime *prometheus.GaugeVec } func newMetrics(register prometheus.Registerer) *metrics { return &metrics{ gcTasksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_tasks_total", "Total number of tasks that have been garbage collected", []string{}, register), + gcPeersCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_peers_total", "Total number of peers that have been garbage collected", []string{}, register), + + gcDisksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_disks_total", + "Total number of garbage collecting the task data in disks", []string{}, register), + + lastGCDisksTime: metricsutils.NewGauge(config.SubsystemSupernode, "last_gc_disks_timestamp_seconds", + "Timestamp of the last disk gc", []string{}, register), } }