From 6d81584d2a3f6ff3ea49296808ec917eb864cd3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=A0=E5=BF=83=E9=9B=B6=E5=BA=A6?= <97019752@qq.com> Date: Tue, 30 Aug 2022 17:34:23 +0800 Subject: [PATCH] reduce unnecessary vmstorage query (#3031) * reduce unnecessary vmstorage query * reduce unnecessary vmstorage query * rollback limit logic /api/v1/label/* --- app/vmselect/prometheus/prometheus.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index d62bd0448..c5ec39e6b 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -616,7 +616,12 @@ func SeriesHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseW if err != nil { return err } - sq := storage.NewSearchQuery(cp.start, cp.end, cp.filterss, *maxSeriesLimit) + + minLimit := *maxSeriesLimit + if limit > 0 && limit < *maxSeriesLimit { + minLimit = limit + } + sq := storage.NewSearchQuery(cp.start, cp.end, cp.filterss, minLimit) metricNames, err := netstorage.SearchMetricNames(qt, sq, cp.deadline) if err != nil { return fmt.Errorf("cannot fetch time series for %q: %w", sq, err)