From f5e70f0ab914198461d5b3ba1ac710e7e244bba2 Mon Sep 17 00:00:00 2001 From: Nikolay Date: Mon, 11 Jan 2021 14:06:54 +0300 Subject: [PATCH] adds multiple match args support for prometheusSearch, (#106) it merges result according to prometheus ChainedSeriesMerge. https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1001 --- app/vmstorage/promdb/promdb.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/vmstorage/promdb/promdb.go b/app/vmstorage/promdb/promdb.go index 0bf37c650..6d4f9ecd3 100644 --- a/app/vmstorage/promdb/promdb.go +++ b/app/vmstorage/promdb/promdb.go @@ -176,14 +176,16 @@ func VisitSeries(sq *storage.SearchQuery, fetchData bool, deadline searchutils.D return err } defer mustCloseQuerier(q) - if len(sq.TagFilterss) != 1 { - return fmt.Errorf("unexpected len(sq.TagFilters); got %d; want 1", len(sq.TagFilterss)) + var seriesSet []promstorage.SeriesSet + for _, tf := range sq.TagFilterss { + ms, err := convertTagFiltersToMatchers(tf) + if err != nil { + return fmt.Errorf("cannot convert tag filters to matchers: %w", err) + } + s := q.Select(false, nil, ms...) + seriesSet = append(seriesSet, s) } - ms, err := convertTagFiltersToMatchers(sq.TagFilterss[0]) - if err != nil { - return fmt.Errorf("cannot convert tag filters to matchers: %w", err) - } - ss := q.Select(false, nil, ms...) + ss := promstorage.NewMergeSeriesSet(seriesSet, promstorage.ChainedSeriesMerge) var ( mn storage.MetricName metricName []byte