From 7643c0cfde2b70c662e46685d7c24124ae666cb2 Mon Sep 17 00:00:00 2001 From: Vladimir Smirnov Date: Sun, 17 May 2020 20:54:46 +0200 Subject: [PATCH] aggregate: function should register all short forms as an alias * This allows groupByNode/groupByNodes to call all available summarizer functions Fixes #466 --- expr/functions/aggregate/function.go | 11 ++++++++++- expr/functions/diffSeries/function.go | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/expr/functions/aggregate/function.go b/expr/functions/aggregate/function.go index ceb589b2a..a06fc01aa 100644 --- a/expr/functions/aggregate/function.go +++ b/expr/functions/aggregate/function.go @@ -24,6 +24,11 @@ func New(configFile string) []interfaces.FunctionMetadata { for _, n := range []string{"aggregate"} { res = append(res, interfaces.FunctionMetadata{Name: n, F: f}) } + + // Also register aliases for each and every summarizer + for _, n := range consolidations.AvailableSummarizers { + res = append(res, interfaces.FunctionMetadata{Name: n, F: f}) + } return res } @@ -36,7 +41,11 @@ func (f *aggregate) Do(e parser.Expr, from, until int64, values map[parser.Metri callback, err := e.GetStringArg(1) if err != nil { - return nil, err + if e.Target() == "aggregate" { + return nil, err + } else { + callback = e.Target() + } } // TODO: Implement xFilesFactor diff --git a/expr/functions/diffSeries/function.go b/expr/functions/diffSeries/function.go index 3baf886d0..34afd6434 100644 --- a/expr/functions/diffSeries/function.go +++ b/expr/functions/diffSeries/function.go @@ -2,12 +2,13 @@ package diffSeries import ( "fmt" + "math" + "strings" + "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" - "math" - "strings" ) type diffSeries struct {