diff --git a/cmd/mockbackend/testcases/consolidateBy/consolidateBy.yaml b/cmd/mockbackend/testcases/consolidateBy/consolidateBy.yaml index 654bfadec..997b89a61 100644 --- a/cmd/mockbackend/testcases/consolidateBy/consolidateBy.yaml +++ b/cmd/mockbackend/testcases/consolidateBy/consolidateBy.yaml @@ -66,7 +66,19 @@ test: URL: "/render?format=json&target=consolidateBy(metric*, 'somefunc')&maxDataPoints=2" expectedResponse: httpCode: 400 - contentType: "text/plain; charset=utf-8" + contentType: "text/plain; charset=utf-8" + - endpoint: "http://127.0.0.1:8081" + type: "GET" + URL: "/render?format=json&target=limit(metric*, 2)&maxDataPoints=2" + expectedResponse: + httpCode: 200 + contentType: "application/json" + - endpoint: "http://127.0.0.1:8081" + type: "GET" + URL: "/render?format=json&target=consolidateBy(seriesByTag('name=rps', 'env=prod'), 'sum')&maxDataPoints=2" + expectedResponse: + httpCode: 200 + contentType: "application/json" listeners: diff --git a/expr/expr.go b/expr/expr.go index 77ef43625..1fba2faec 100644 --- a/expr/expr.go +++ b/expr/expr.go @@ -55,9 +55,9 @@ func (eval Evaluator) Fetch(ctx context.Context, exprs []parser.Expr, from, unti Until: fetchRequest.StopTime, } - if eval.passFunctionsToBackend { + if eval.passFunctionsToBackend && m.ConsolidationFunc != "" { if _, ok := consolidateBy.ValidAggregateFunctions[m.ConsolidationFunc]; !ok { - return nil, merry.WithMessagef(parser.ErrInvalidArg, "invalid consolidateBy argument: %s", m.ConsolidationFunc) + return nil, merry.WithMessagef(parser.ErrInvalidArg, "invalid consolidateBy argument: '%s'", m.ConsolidationFunc) } fetchRequest.FilterFunctions = append(fetchRequest.FilterFunctions, &pb.FilteringFunction{ Name: "consolidateBy",