From af9033f3e00f1598cc6fcf61213ecf4b7576ab5d Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 26 Sep 2018 15:44:09 +0200 Subject: [PATCH] stackdriver: distinct grafana auto from stackdriver auto in alignment period --- pkg/tsdb/stackdriver/stackdriver.go | 2 +- pkg/tsdb/stackdriver/stackdriver_test.go | 6 +++--- public/app/plugins/datasource/stackdriver/constants.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/tsdb/stackdriver/stackdriver.go b/pkg/tsdb/stackdriver/stackdriver.go index 6d8c76d5ba1..5e65e0ae527 100644 --- a/pkg/tsdb/stackdriver/stackdriver.go +++ b/pkg/tsdb/stackdriver/stackdriver.go @@ -184,7 +184,7 @@ func setAggParams(params *url.Values, query *tsdb.Query) { perSeriesAligner = "ALIGN_MEAN" } - if alignmentPeriod == "auto" || alignmentPeriod == "" { + if alignmentPeriod == "grafana-auto" || alignmentPeriod == "" { alignmentPeriodValue := int(math.Max(float64(query.IntervalMs), 60.0)) alignmentPeriod = "+" + strconv.Itoa(alignmentPeriodValue) + "s" } diff --git a/pkg/tsdb/stackdriver/stackdriver_test.go b/pkg/tsdb/stackdriver/stackdriver_test.go index 9ec47fee4ea..f8b56fdff07 100644 --- a/pkg/tsdb/stackdriver/stackdriver_test.go +++ b/pkg/tsdb/stackdriver/stackdriver_test.go @@ -67,12 +67,12 @@ func TestStackdriver(t *testing.T) { So(queries[0].Params["filter"][0], ShouldEqual, `metric.type="a/metric/type" key="value" key2="value2"`) }) - Convey("and alignmentPeriod is set to auto", func() { + Convey("and alignmentPeriod is set to grafana-auto", func() { Convey("and IntervalMs is larger than 60", func() { tsdbQuery.Queries[0].IntervalMs = 1000 tsdbQuery.Queries[0].Model = simplejson.NewFromAny(map[string]interface{}{ "target": "target", - "alignmentPeriod": "auto", + "alignmentPeriod": "grafana-auto", "filters": []interface{}{"key", "=", "value", "AND", "key2", "=", "value2"}, }) @@ -84,7 +84,7 @@ func TestStackdriver(t *testing.T) { tsdbQuery.Queries[0].IntervalMs = 30 tsdbQuery.Queries[0].Model = simplejson.NewFromAny(map[string]interface{}{ "target": "target", - "alignmentPeriod": "auto", + "alignmentPeriod": "grafana-auto", "filters": []interface{}{"key", "=", "value", "AND", "key2", "=", "value2"}, }) diff --git a/public/app/plugins/datasource/stackdriver/constants.ts b/public/app/plugins/datasource/stackdriver/constants.ts index 272b03af218..64674a5eb3f 100644 --- a/public/app/plugins/datasource/stackdriver/constants.ts +++ b/public/app/plugins/datasource/stackdriver/constants.ts @@ -243,7 +243,8 @@ export const aggOptions = [ ]; export const alignmentPeriods = [ - { text: 'auto', value: 'auto' }, + { text: 'grafana auto', value: 'grafana-auto' }, + { text: 'stackdriver auto', value: 'stackdriver-auto' }, { text: '1m', value: '+60s' }, { text: '5m', value: '+300s' }, { text: '30m', value: '+1800s' },