From 4e6a77cad002b0b4fe9f899b255fe8da3466fa33 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 28 May 2021 11:38:31 +0300 Subject: [PATCH] Fix trendValue/consolidateBy --- pkg/datasource/functions.go | 10 ++++++---- pkg/datasource/zabbix.go | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/datasource/functions.go b/pkg/datasource/functions.go index 4d77e24..cd1db7d 100644 --- a/pkg/datasource/functions.go +++ b/pkg/datasource/functions.go @@ -53,7 +53,7 @@ var filterFuncMap map[string]AggDataProcessingFunc var timeFuncMap map[string]PreProcessingFunc -var frontendFuncMap map[string]bool +var skippedFuncMap map[string]bool func init() { seriesFuncMap = map[string]DataProcessingFunc{ @@ -87,11 +87,13 @@ func init() { "timeShift": applyTimeShiftPre, } - // Functions processing on the frontend - frontendFuncMap = map[string]bool{ + // Functions not processing here or processing on the frontend, skip it + skippedFuncMap = map[string]bool{ "setAlias": true, "replaceAlias": true, "setAliasByRegex": true, + "trendValue": true, + "consolidateBy": true, } } @@ -117,7 +119,7 @@ func applyFunctions(series []*timeseries.TimeSeriesData, functions []QueryFuncti return nil, err } series = result - } else if _, ok := frontendFuncMap[f.Def.Name]; ok { + } else if _, ok := skippedFuncMap[f.Def.Name]; ok { continue } else { err := errFunctionNotSupported(f.Def.Name) diff --git a/pkg/datasource/zabbix.go b/pkg/datasource/zabbix.go index c761b30..68f4e8b 100644 --- a/pkg/datasource/zabbix.go +++ b/pkg/datasource/zabbix.go @@ -73,7 +73,7 @@ func (ds *ZabbixDatasourceInstance) queryNumericDataForItems(ctx context.Context return nil, err } - history, err := ds.getHistotyOrTrend(ctx, query, items, valueType) + history, err := ds.getHistotyOrTrend(ctx, query, items, consolidateBy) if err != nil { return nil, err } @@ -101,7 +101,7 @@ func (ds *ZabbixDatasourceInstance) getTrendValueType(query *QueryModel) string } func (ds *ZabbixDatasourceInstance) getConsolidateBy(query *QueryModel) string { - consolidateBy := "avg" + consolidateBy := "" for _, fn := range query.Functions { if fn.Def.Name == "consolidateBy" && len(fn.Params) > 0 {