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)