From 9b6746d8086a44a8b2fadca5e5acebcbfd4b9843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Edstr=C3=B6m?= Date: Tue, 29 Jan 2019 19:11:54 +0100 Subject: [PATCH] Change primaryAggregation to crossSeriesReducer in Stackdriver --- pkg/tsdb/stackdriver/stackdriver.go | 8 ++++---- pkg/tsdb/stackdriver/stackdriver_test.go | 8 ++++---- public/app/plugins/datasource/stackdriver/datasource.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/tsdb/stackdriver/stackdriver.go b/pkg/tsdb/stackdriver/stackdriver.go index 2ad47cc4b83..8317e2a748a 100644 --- a/pkg/tsdb/stackdriver/stackdriver.go +++ b/pkg/tsdb/stackdriver/stackdriver.go @@ -233,12 +233,12 @@ func buildFilterString(metricType string, filterParts []interface{}) string { } func setAggParams(params *url.Values, query *tsdb.Query, durationSeconds int) { - primaryAggregation := query.Model.Get("primaryAggregation").MustString() + crossSeriesReducer := query.Model.Get("crossSeriesReducer").MustString() perSeriesAligner := query.Model.Get("perSeriesAligner").MustString() alignmentPeriod := query.Model.Get("alignmentPeriod").MustString() - if primaryAggregation == "" { - primaryAggregation = "REDUCE_NONE" + if crossSeriesReducer == "" { + crossSeriesReducer = "REDUCE_NONE" } if perSeriesAligner == "" { @@ -267,7 +267,7 @@ func setAggParams(params *url.Values, query *tsdb.Query, durationSeconds int) { alignmentPeriod = "+3600s" } - params.Add("aggregation.crossSeriesReducer", primaryAggregation) + params.Add("aggregation.crossSeriesReducer", crossSeriesReducer) params.Add("aggregation.perSeriesAligner", perSeriesAligner) params.Add("aggregation.alignmentPeriod", alignmentPeriod) diff --git a/pkg/tsdb/stackdriver/stackdriver_test.go b/pkg/tsdb/stackdriver/stackdriver_test.go index 784bf4a7fbb..4b16b6b5294 100644 --- a/pkg/tsdb/stackdriver/stackdriver_test.go +++ b/pkg/tsdb/stackdriver/stackdriver_test.go @@ -173,7 +173,7 @@ func TestStackdriver(t *testing.T) { Convey("and query has aggregation mean set", func() { tsdbQuery.Queries[0].Model = simplejson.NewFromAny(map[string]interface{}{ "metricType": "a/metric/type", - "primaryAggregation": "REDUCE_MEAN", + "crossSeriesReducer": "REDUCE_SUM", "view": "FULL", }) @@ -182,11 +182,11 @@ func TestStackdriver(t *testing.T) { So(len(queries), ShouldEqual, 1) So(queries[0].RefID, ShouldEqual, "A") - So(queries[0].Target, ShouldEqual, "aggregation.alignmentPeriod=%2B60s&aggregation.crossSeriesReducer=REDUCE_MEAN&aggregation.perSeriesAligner=ALIGN_MEAN&filter=metric.type%3D%22a%2Fmetric%2Ftype%22&interval.endTime=2018-03-15T13%3A34%3A00Z&interval.startTime=2018-03-15T13%3A00%3A00Z&view=FULL") + So(queries[0].Target, ShouldEqual, "aggregation.alignmentPeriod=%2B60s&aggregation.crossSeriesReducer=REDUCE_SUM&aggregation.perSeriesAligner=ALIGN_MEAN&filter=metric.type%3D%22a%2Fmetric%2Ftype%22&interval.endTime=2018-03-15T13%3A34%3A00Z&interval.startTime=2018-03-15T13%3A00%3A00Z&view=FULL") So(len(queries[0].Params), ShouldEqual, 7) So(queries[0].Params["interval.startTime"][0], ShouldEqual, "2018-03-15T13:00:00Z") So(queries[0].Params["interval.endTime"][0], ShouldEqual, "2018-03-15T13:34:00Z") - So(queries[0].Params["aggregation.crossSeriesReducer"][0], ShouldEqual, "REDUCE_MEAN") + So(queries[0].Params["aggregation.crossSeriesReducer"][0], ShouldEqual, "REDUCE_SUM") So(queries[0].Params["aggregation.perSeriesAligner"][0], ShouldEqual, "ALIGN_MEAN") So(queries[0].Params["aggregation.alignmentPeriod"][0], ShouldEqual, "+60s") So(queries[0].Params["filter"][0], ShouldEqual, "metric.type=\"a/metric/type\"") @@ -196,7 +196,7 @@ func TestStackdriver(t *testing.T) { Convey("and query has group bys", func() { tsdbQuery.Queries[0].Model = simplejson.NewFromAny(map[string]interface{}{ "metricType": "a/metric/type", - "primaryAggregation": "REDUCE_NONE", + "crossSeriesReducer": "REDUCE_NONE", "groupBys": []interface{}{"metric.label.group1", "metric.label.group2"}, "view": "FULL", }) diff --git a/public/app/plugins/datasource/stackdriver/datasource.ts b/public/app/plugins/datasource/stackdriver/datasource.ts index 3e29747cc95..025955105a7 100644 --- a/public/app/plugins/datasource/stackdriver/datasource.ts +++ b/public/app/plugins/datasource/stackdriver/datasource.ts @@ -34,7 +34,7 @@ export default class StackdriverDatasource { intervalMs: options.intervalMs, datasourceId: this.id, metricType: this.templateSrv.replace(t.metricType, options.scopedVars || {}), - primaryAggregation: this.templateSrv.replace(t.crossSeriesReducer || 'REDUCE_MEAN', options.scopedVars || {}), + crossSeriesReducer: this.templateSrv.replace(t.crossSeriesReducer || 'REDUCE_MEAN', options.scopedVars || {}), perSeriesAligner: this.templateSrv.replace(t.perSeriesAligner, options.scopedVars || {}), alignmentPeriod: this.templateSrv.replace(t.alignmentPeriod, options.scopedVars || {}), groupBys: this.interpolateGroupBys(t.groupBys, options.scopedVars), @@ -138,7 +138,7 @@ export default class StackdriverDatasource { refId: 'annotationQuery', datasourceId: this.id, metricType: this.templateSrv.replace(annotation.target.metricType, options.scopedVars || {}), - primaryAggregation: 'REDUCE_NONE', + crossSeriesReducer: 'REDUCE_NONE', perSeriesAligner: 'ALIGN_NONE', title: this.templateSrv.replace(annotation.target.title, options.scopedVars || {}), text: this.templateSrv.replace(annotation.target.text, options.scopedVars || {}),