From 91faa152a517170a9c616894a49843598a4b2287 Mon Sep 17 00:00:00 2001 From: guidao Date: Wed, 13 Jul 2022 17:37:04 +0800 Subject: [PATCH] add next retention metric (#2863) Co-authored-by: wangfeng --- app/vmstorage/main.go | 4 ++++ lib/storage/storage.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index 987e23439..5747dd01d 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -846,6 +846,10 @@ func registerStorageMetrics(strg *storage.Storage) { metrics.NewGauge(`vm_cache_collisions_total{type="storage/metricName"}`, func() float64 { return float64(m().MetricNameCacheCollisions) }) + + metrics.NewGauge(`vm_next_retention_seconds`, func() float64 { + return float64(m().NextRetentionSeconds) + }) } func jsonResponseError(w http.ResponseWriter, err error) { diff --git a/lib/storage/storage.go b/lib/storage/storage.go index 8396bfc85..8b68395aa 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -511,6 +511,8 @@ type Metrics struct { PrefetchedMetricIDsSize uint64 PrefetchedMetricIDsSizeBytes uint64 + NextRetentionSeconds uint64 + IndexDBMetrics IndexDBMetrics TableMetrics TableMetrics } @@ -601,6 +603,8 @@ func (s *Storage) UpdateMetrics(m *Metrics) { m.PrefetchedMetricIDsSize += uint64(prefetchedMetricIDs.Len()) m.PrefetchedMetricIDsSizeBytes += uint64(prefetchedMetricIDs.SizeBytes()) + m.NextRetentionSeconds = uint64(nextRetentionDuration(s.retentionMsecs).Seconds()) + s.idb().UpdateMetrics(&m.IndexDBMetrics) s.tb.UpdateMetrics(&m.TableMetrics) }