From 83da9399479bb4aa120d1ef42fb1920651a8f725 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 17 Feb 2021 19:13:38 +0200 Subject: [PATCH] app/vmstorage: export vm_composite_filter_success_conversions_total and vm_composite_filter_missing_conversions_total metrics --- app/vmstorage/main.go | 6 ++++++ lib/storage/index_db.go | 6 +++++- lib/storage/tag_filters.go | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index fe1126ef3..e4b9a8a85 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -332,6 +332,12 @@ func registerStorageMetrics(strg *storage.Storage) { metrics.NewGauge(`vm_composite_index_min_timestamp`, func() float64 { return float64(idbm().MinTimestampForCompositeIndex) / 1e3 }) + metrics.NewGauge(`vm_composite_filter_success_conversions_total`, func() float64 { + return float64(idbm().CompositeFilterSuccessConversions) + }) + metrics.NewGauge(`vm_composite_filter_missing_conversions_total`, func() float64 { + return float64(idbm().CompositeFilterMissingConversions) + }) metrics.NewGauge(`vm_assisted_merges_total{type="storage/small"}`, func() float64 { return float64(tm().SmallAssistedMerges) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 0f6e07242..c74824176 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -205,7 +205,9 @@ type IndexDBMetrics struct { IndexBlocksWithMetricIDsProcessed uint64 IndexBlocksWithMetricIDsIncorrectOrder uint64 - MinTimestampForCompositeIndex uint64 + MinTimestampForCompositeIndex uint64 + CompositeFilterSuccessConversions uint64 + CompositeFilterMissingConversions uint64 mergeset.TableMetrics } @@ -249,6 +251,8 @@ func (db *indexDB) UpdateMetrics(m *IndexDBMetrics) { m.IndexBlocksWithMetricIDsIncorrectOrder = atomic.LoadUint64(&indexBlocksWithMetricIDsIncorrectOrder) m.MinTimestampForCompositeIndex = uint64(db.minTimestampForCompositeIndex) + m.CompositeFilterSuccessConversions = atomic.LoadUint64(&compositeFilterSuccessConversions) + m.CompositeFilterMissingConversions = atomic.LoadUint64(&compositeFilterMissingConversions) db.tb.UpdateMetrics(&m.TableMetrics) db.doExtDB(func(extDB *indexDB) { diff --git a/lib/storage/tag_filters.go b/lib/storage/tag_filters.go index c0732a722..39b4a9483 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -37,6 +37,7 @@ func convertToCompositeTagFilters(tfs *TagFilters) *TagFilters { } if len(name) == 0 { // There is no metric name filter, so composite filters cannot be created. + atomic.AddUint64(&compositeFilterMissingConversions, 1) return tfs } tfsNew := make([]tagFilter, 0, len(tfs.tfs)) @@ -62,13 +63,20 @@ func convertToCompositeTagFilters(tfs *TagFilters) *TagFilters { compositeFilters++ } if compositeFilters == 0 { + atomic.AddUint64(&compositeFilterMissingConversions, 1) return tfs } tfsCompiled := NewTagFilters(tfs.accountID, tfs.projectID) tfsCompiled.tfs = tfsNew + atomic.AddUint64(&compositeFilterSuccessConversions, 1) return tfsCompiled } +var ( + compositeFilterSuccessConversions uint64 + compositeFilterMissingConversions uint64 +) + // TagFilters represents filters used for filtering tags. type TagFilters struct { accountID uint32