فهرست منبع

Change primaryAggregation to crossSeriesReducer in Stackdriver

Robert Edström 7 سال پیش
والد
کامیت
9b6746d808

+ 4 - 4
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)
 

+ 4 - 4
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",
 				})

+ 2 - 2
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 || {}),