From 0b7a23a91d5f29535c3c485f0c1d92f87ae91fef Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 29 Feb 2024 23:39:56 +0200 Subject: [PATCH] app/vmselect/prometheus: ignore match[] additionally to extra_filters[] and extra_label if -search.ignoreExtraFiltersAtLabelsAPI command-line flag is set The match[] at /api/v1/labels and /api/v1/label/.../values also may lead to slow requests and high resource usage if it matches big number of time series. So it must be igrnored if -search.ignoreExtraFiltersAtLabelsAPI command-line flag is set. This is a follow-up for fab02faa3f7c80d76bb28dc118fc7398abcfe544 --- app/vmselect/prometheus/prometheus.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 5a296b2bf..a897bdf7b 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -59,8 +59,8 @@ var ( "This option doesn't limit the number of scanned raw samples in the database. The main purpose of this option is to limit the number of per-series points "+ "returned to graphing UI such as VMUI or Grafana. There is no sense in setting this limit to values bigger than the horizontal resolution of the graph. "+ "See also -search.maxResponseSeries") - ignoreExtraFiltersAtLabelsAPI = flag.Bool("search.ignoreExtraFiltersAtLabelsAPI", false, "Whether to ignore extra_filters and extra_label query args at "+ - "/api/v1/labels, /api/v1/label/.../values and /api/v1/series . This may be useful for decreasing load on VictoriaMetrics when extra filters "+ + ignoreExtraFiltersAtLabelsAPI = flag.Bool("search.ignoreExtraFiltersAtLabelsAPI", false, "Whether to ignore match[], extra_filters[] and extra_label query args at "+ + "/api/v1/labels and /api/v1/label/.../values . This may be useful for decreasing load on VictoriaMetrics when extra filters "+ "match too many time series. The downside is that suprflouos labels or series could be returned, which do not match the extra filters. "+ "See also -search.maxLabelsAPISeries and -search.maxLabelsAPIDuration") ) @@ -1181,18 +1181,18 @@ func getCommonParamsInternal(r *http.Request, startTime time.Time, requireNonEmp if requireNonEmptyMatch && len(matches) == 0 { return nil, fmt.Errorf("missing `match[]` arg") } - tagFilterss, err := getTagFilterssFromMatches(matches) - if err != nil { - return nil, err - } - filterss := tagFilterss + var filterss [][]storage.TagFilter if !isLabelsAPI || !*ignoreExtraFiltersAtLabelsAPI { + tagFilterss, err := getTagFilterssFromMatches(matches) + if err != nil { + return nil, err + } etfs, err := searchutils.GetExtraTagFilters(r) if err != nil { return nil, err } - filterss = searchutils.JoinTagFilterss(filterss, etfs) + filterss = searchutils.JoinTagFilterss(tagFilterss, etfs) } cp := &commonParams{