From d4849561efa00ed6c38aedfcd1cedc99999053d5 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 3a5f4bfe1..4a96fd130 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -448,6 +448,12 @@ func registerStorageMetrics() { 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 4a1759408..c6ade8c65 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 5d62cbc04..67a373f4e 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -36,6 +36,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)) @@ -61,13 +62,20 @@ func convertToCompositeTagFilters(tfs *TagFilters) *TagFilters { compositeFilters++ } if compositeFilters == 0 { + atomic.AddUint64(&compositeFilterMissingConversions, 1) return tfs } tfsCompiled := NewTagFilters() tfsCompiled.tfs = tfsNew + atomic.AddUint64(&compositeFilterSuccessConversions, 1) return tfsCompiled } +var ( + compositeFilterSuccessConversions uint64 + compositeFilterMissingConversions uint64 +) + // TagFilters represents filters used for filtering tags. type TagFilters struct { tfs []tagFilter