From d297b650891a294eb2e9a00171d702d6b30e43f1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 13 Nov 2019 19:00:02 +0200 Subject: [PATCH] lib/storage: add `vm_cache_size_bytes{type="storage/hour_metric_ids"}` metric --- app/vmstorage/main.go | 3 +++ lib/storage/storage.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index c1e7855dd4..1fff4a3667 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -415,6 +415,9 @@ func registerStorageMetrics(strg *storage.Storage) { metrics.NewGauge(`vm_cache_size_bytes{type="storage/date_metricID"}`, func() float64 { return float64(m().DateMetricIDCacheSizeBytes) }) + metrics.NewGauge(`vm_cache_size_bytes{type="storage/hour_metric_ids"}`, func() float64 { + return float64(m().HourMetricIDCacheSizeBytes) + }) metrics.NewGauge(`vm_cache_size_bytes{type="indexdb/tagFilters"}`, func() float64 { return float64(idbm().TagCacheSizeBytes) }) diff --git a/lib/storage/storage.go b/lib/storage/storage.go index b44a5c2e0d..d1f3f2fa70 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -320,7 +320,8 @@ type Metrics struct { DateMetricIDCacheSyncsCount uint64 DateMetricIDCacheResetsCount uint64 - HourMetricIDCacheSize uint64 + HourMetricIDCacheSize uint64 + HourMetricIDCacheSizeBytes uint64 IndexDBMetrics IndexDBMetrics TableMetrics TableMetrics @@ -378,6 +379,8 @@ func (s *Storage) UpdateMetrics(m *Metrics) { hourMetricIDsLen = hmCurr.m.Len() } m.HourMetricIDCacheSize += uint64(hourMetricIDsLen) + m.HourMetricIDCacheSizeBytes += hmCurr.m.SizeBytes() + m.HourMetricIDCacheSizeBytes += hmPrev.m.SizeBytes() s.idb().UpdateMetrics(&m.IndexDBMetrics) s.tb.UpdateMetrics(&m.TableMetrics)