From f41e6a7bd9aeb3ef5f3d967d915d89a73f12468f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 17 Apr 2020 12:24:10 +0300 Subject: [PATCH] app/vmselect: properly apply `-search.maxLookback` to queries sent to `/api/v1/query` --- app/vmselect/prometheus/prometheus.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 7c988d4b9..3a4dfd42f 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -576,15 +576,18 @@ func QueryHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) e if err != nil { return err } - step, err := getDuration(r, "step", defaultStep) - if err != nil { - return err - } - deadline := getDeadlineForQuery(r) lookbackDelta, err := getMaxLookback(r) if err != nil { return err } + step, err := getDuration(r, "step", lookbackDelta) + if err != nil { + return err + } + if step <= 0 { + step = defaultStep + } + deadline := getDeadlineForQuery(r) if len(query) > *maxQueryLen { return fmt.Errorf("too long query; got %d bytes; mustn't exceed `-search.maxQueryLen=%d` bytes", len(query), *maxQueryLen)