diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 8ab587d4fa..f89c5fb5b6 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -610,7 +610,7 @@ var labelValuesDuration = metrics.NewSummary(`vm_request_duration_seconds{path=" // LabelsCountHandler processes /api/v1/labels/count request. func LabelsCountHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error { - deadline := searchutils.GetDeadlineForQuery(r, startTime) + deadline := searchutils.GetDeadlineForStatusRequest(r, startTime) labelEntries, err := netstorage.GetLabelEntries(deadline) if err != nil { return fmt.Errorf(`cannot obtain label entries: %w`, err) @@ -634,7 +634,7 @@ const secsPerDay = 3600 * 24 // // See https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-stats func TSDBStatusHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error { - deadline := searchutils.GetDeadlineForQuery(r, startTime) + deadline := searchutils.GetDeadlineForStatusRequest(r, startTime) if err := r.ParseForm(); err != nil { return fmt.Errorf("cannot parse form values: %w", err) } @@ -810,7 +810,7 @@ var labelsDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/api/ // SeriesCountHandler processes /api/v1/series/count request. func SeriesCountHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error { - deadline := searchutils.GetDeadlineForQuery(r, startTime) + deadline := searchutils.GetDeadlineForStatusRequest(r, startTime) n, err := netstorage.GetSeriesCount(deadline) if err != nil { return fmt.Errorf("cannot obtain series count: %w", err) diff --git a/app/vmselect/searchutils/searchutils.go b/app/vmselect/searchutils/searchutils.go index 1033f6ba1f..93dc1fbcfb 100644 --- a/app/vmselect/searchutils/searchutils.go +++ b/app/vmselect/searchutils/searchutils.go @@ -16,8 +16,9 @@ import ( ) var ( - maxExportDuration = flag.Duration("search.maxExportDuration", time.Hour*24*30, "The maximum duration for /api/v1/export call") - maxQueryDuration = flag.Duration("search.maxQueryDuration", time.Second*30, "The maximum duration for query execution") + maxExportDuration = flag.Duration("search.maxExportDuration", time.Hour*24*30, "The maximum duration for /api/v1/export call") + maxQueryDuration = flag.Duration("search.maxQueryDuration", time.Second*30, "The maximum duration for query execution") + maxStatusRequestDuration = flag.Duration("search.maxStatusRequestDuration", time.Minute*5, "The maximum duration for /api/v1/status/* requests") ) func roundToSeconds(ms int64) int64 { @@ -125,6 +126,12 @@ func GetDeadlineForQuery(r *http.Request, startTime time.Time) Deadline { return getDeadlineWithMaxDuration(r, startTime, dMax, "-search.maxQueryDuration") } +// GetDeadlineForStatusRequest returns deadline for the given request to /api/v1/status/*. +func GetDeadlineForStatusRequest(r *http.Request, startTime time.Time) Deadline { + dMax := maxStatusRequestDuration.Milliseconds() + return getDeadlineWithMaxDuration(r, startTime, dMax, "-search.maxStatusRequestDuration") +} + // GetDeadlineForExport returns deadline for the given request to /api/v1/export. func GetDeadlineForExport(r *http.Request, startTime time.Time) Deadline { dMax := maxExportDuration.Milliseconds()