From 8cb1e5b918c77c66ec077406ddbdcde9fa2a3905 Mon Sep 17 00:00:00 2001 From: z0029c4 Date: Wed, 13 Feb 2019 17:55:31 +0530 Subject: [PATCH 1/2] added support for influxdb non_negative_difference function in tsdb for alerting --- pkg/tsdb/influxdb/query_part.go | 1 + pkg/tsdb/influxdb/query_part_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/tsdb/influxdb/query_part.go b/pkg/tsdb/influxdb/query_part.go index 29a77f15617..e81da28fd4d 100644 --- a/pkg/tsdb/influxdb/query_part.go +++ b/pkg/tsdb/influxdb/query_part.go @@ -33,6 +33,7 @@ func init() { renders["sum"] = QueryDefinition{Renderer: functionRenderer} renders["mode"] = QueryDefinition{Renderer: functionRenderer} renders["cumulative_sum"] = QueryDefinition{Renderer: functionRenderer} + renders["non_negative_difference"] = QueryDefinition{Renderer: functionRenderer} renders["holt_winters"] = QueryDefinition{ Renderer: functionRenderer, diff --git a/pkg/tsdb/influxdb/query_part_test.go b/pkg/tsdb/influxdb/query_part_test.go index 76daf6446d8..35ebbe0a13f 100644 --- a/pkg/tsdb/influxdb/query_part_test.go +++ b/pkg/tsdb/influxdb/query_part_test.go @@ -24,6 +24,7 @@ func TestInfluxdbQueryPart(t *testing.T) { {mode: "count", params: []string{}, input: "distinct(value)", expected: `count(distinct(value))`}, {mode: "mode", params: []string{}, input: "value", expected: `mode(value)`}, {mode: "cumulative_sum", params: []string{}, input: "mean(value)", expected: `cumulative_sum(mean(value))`}, + {mode: "non_negative_difference", params: []string{}, input: "max("value")", expected: `non_negative_difference(max("value"))`}, } queryContext := &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("5m", "now")} From 13974cdd28a636c13263ea6c81e1f1557e0f1c47 Mon Sep 17 00:00:00 2001 From: z0029c4 Date: Wed, 13 Feb 2019 18:12:35 +0530 Subject: [PATCH 2/2] added support for influxdb non_negative_difference function in tsdb --- pkg/tsdb/influxdb/query_part_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tsdb/influxdb/query_part_test.go b/pkg/tsdb/influxdb/query_part_test.go index 35ebbe0a13f..915c066b460 100644 --- a/pkg/tsdb/influxdb/query_part_test.go +++ b/pkg/tsdb/influxdb/query_part_test.go @@ -24,7 +24,7 @@ func TestInfluxdbQueryPart(t *testing.T) { {mode: "count", params: []string{}, input: "distinct(value)", expected: `count(distinct(value))`}, {mode: "mode", params: []string{}, input: "value", expected: `mode(value)`}, {mode: "cumulative_sum", params: []string{}, input: "mean(value)", expected: `cumulative_sum(mean(value))`}, - {mode: "non_negative_difference", params: []string{}, input: "max("value")", expected: `non_negative_difference(max("value"))`}, + {mode: "non_negative_difference", params: []string{}, input: "max(value)", expected: `non_negative_difference(max(value))`}, } queryContext := &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("5m", "now")}