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 fab02faa3f
This commit is contained in:
Aliaksandr Valialkin 2024-02-29 23:39:56 +02:00
parent cfe774ab50
commit 0b7a23a91d
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB

View File

@ -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 "+ "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. "+ "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") "See also -search.maxResponseSeries")
ignoreExtraFiltersAtLabelsAPI = flag.Bool("search.ignoreExtraFiltersAtLabelsAPI", false, "Whether to ignore extra_filters and extra_label query args at "+ ignoreExtraFiltersAtLabelsAPI = flag.Bool("search.ignoreExtraFiltersAtLabelsAPI", false, "Whether to ignore match[], 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 "+ "/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. "+ "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") "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 { if requireNonEmptyMatch && len(matches) == 0 {
return nil, fmt.Errorf("missing `match[]` arg") 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 { if !isLabelsAPI || !*ignoreExtraFiltersAtLabelsAPI {
tagFilterss, err := getTagFilterssFromMatches(matches)
if err != nil {
return nil, err
}
etfs, err := searchutils.GetExtraTagFilters(r) etfs, err := searchutils.GetExtraTagFilters(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }
filterss = searchutils.JoinTagFilterss(filterss, etfs) filterss = searchutils.JoinTagFilterss(tagFilterss, etfs)
} }
cp := &commonParams{ cp := &commonParams{