From 1c18ef489a37d350fdafd84aa76fa807e2b886d9 Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Mon, 26 Sep 2022 02:26:14 -0700 Subject: [PATCH] split interval middleware sends query when start equals false (#5714) Signed-off-by: Ben Ye Signed-off-by: Ben Ye --- .../querier/queryrange/split_by_interval.go | 5 +++++ .../queryrange/split_by_interval_test.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/internal/cortex/querier/queryrange/split_by_interval.go b/internal/cortex/querier/queryrange/split_by_interval.go index 2db7edceaf..9899b7ecbd 100644 --- a/internal/cortex/querier/queryrange/split_by_interval.go +++ b/internal/cortex/querier/queryrange/split_by_interval.go @@ -70,6 +70,11 @@ func (s splitByInterval) Do(ctx context.Context, r Request) (Response, error) { } func splitQuery(r Request, interval time.Duration) ([]Request, error) { + // If Start == end we should just run the original request. + if r.GetStart() == r.GetEnd() { + return []Request{r}, nil + } + // Replace @ modifier function to their respective constant values in the query. // This way subqueries will be evaluated at the same time as the parent query. query, err := evaluateAtModifierFunction(r.GetQuery(), r.GetStart(), r.GetEnd()) diff --git a/internal/cortex/querier/queryrange/split_by_interval_test.go b/internal/cortex/querier/queryrange/split_by_interval_test.go index fe32b71dfb..b4b5bf8013 100644 --- a/internal/cortex/querier/queryrange/split_by_interval_test.go +++ b/internal/cortex/querier/queryrange/split_by_interval_test.go @@ -85,6 +85,23 @@ func TestSplitQuery(t *testing.T) { }, interval: day, }, + { + input: &PrometheusRequest{ + Start: 60 * 60 * seconds, + End: 60 * 60 * seconds, + Step: 15 * seconds, + Query: "foo", + }, + expected: []Request{ + &PrometheusRequest{ + Start: 60 * 60 * seconds, + End: 60 * 60 * seconds, + Step: 15 * seconds, + Query: "foo", + }, + }, + interval: day, + }, { input: &PrometheusRequest{ Start: 0,