add next retention metric (#2863)

Co-authored-by: wangfeng <wangfeng@zhihu.com>
This commit is contained in:
guidao 2022-07-13 17:37:04 +08:00 committed by Aliaksandr Valialkin
parent 919939ee9f
commit f2d24a660b
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 8 additions and 0 deletions

View file

@ -753,6 +753,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) {

View file

@ -526,6 +526,8 @@ type Metrics struct {
PrefetchedMetricIDsSize uint64
PrefetchedMetricIDsSizeBytes uint64
NextRetentionSeconds uint64
IndexDBMetrics IndexDBMetrics
TableMetrics TableMetrics
}
@ -616,6 +618,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)
}