From c5435596ad089df6950fb020852502c42508a5f5 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 30 Oct 2015 22:34:40 -0700 Subject: [PATCH 01/10] Added All Value support for custom type templating --- .../features/templating/partials/editor.html | 17 +++++++++++++++++ .../features/templating/templateValuesSrv.js | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 63ecd00adcf..133886971bd 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -146,6 +146,23 @@
+
+ +
+
diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 18216fabd0f..a82eca012e6 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -115,6 +115,11 @@ function (angular, _, kbn) { if (variable.type === 'interval') { self.updateAutoInterval(variable); } + + if (variable.type === 'custom' && variable.includeAll) { + self.addAllOption(variable); + } + }; this.updateOptions = function(variable) { From 65bc194c422b10b5a2b6541e438062b82bead796 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Tue, 10 Nov 2015 19:01:37 +0900 Subject: [PATCH 02/10] fix templating error dialog for Prometheus --- public/app/services/backendSrv.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/app/services/backendSrv.js b/public/app/services/backendSrv.js index 819ce9d938e..dcd922b886d 100644 --- a/public/app/services/backendSrv.js +++ b/public/app/services/backendSrv.js @@ -106,6 +106,11 @@ function (angular, _, config) { }); } + // for Prometheus + if (!err.data.message && _.isString(err.data.error)) { + err.data.message = err.data.error; + } + throw err; }); }; From 5339ec66b7dcdbb7fcc78b20088f5ee268d7e24e Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 10 Nov 2015 02:22:15 -0800 Subject: [PATCH 03/10] added now-3h option --- public/app/core/utils/rangeutil.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 1e64fcc0061..5975ccbd181 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -34,11 +34,12 @@ var rangeOptions = [ { from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 3 }, { from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 3 }, { from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 3 }, + { from: 'now-3h', to: 'now', display: 'Last 3 hour', section: 3 }, { from: 'now-6h', to: 'now', display: 'Last 6 hours', section: 3 }, { from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 3 }, { from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 3 }, - { from: 'now-7d', to: 'now', display: 'Last 7 days', section: 3 }, + { from: 'now-7d', to: 'now', display: 'Last 7 days', section: 0 }, { from: 'now-30d', to: 'now', display: 'Last 30 days', section: 0 }, { from: 'now-60d', to: 'now', display: 'Last 60 days', section: 0 }, { from: 'now-90d', to: 'now', display: 'Last 90 days', section: 0 }, From 0c50a7437b19fa13c178c1191c3b813512c297b8 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 10 Nov 2015 02:29:02 -0800 Subject: [PATCH 04/10] missed an S at the end --- public/app/core/utils/rangeutil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 5975ccbd181..21fea34fe68 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -34,7 +34,7 @@ var rangeOptions = [ { from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 3 }, { from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 3 }, { from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 3 }, - { from: 'now-3h', to: 'now', display: 'Last 3 hour', section: 3 }, + { from: 'now-3h', to: 'now', display: 'Last 3 hours', section: 3 }, { from: 'now-6h', to: 'now', display: 'Last 6 hours', section: 3 }, { from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 3 }, { from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 3 }, From 167c02d7731049a20699ba767cc2783a023bc86f Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 10 Nov 2015 04:53:42 -0800 Subject: [PATCH 05/10] Timepicker display fixed for now-* --- public/app/core/utils/rangeutil.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 1e64fcc0061..3fc4252ceaf 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -133,6 +133,10 @@ _.each(rangeOptions, function (frame) { return from.fromNow() + ' to ' + formatDate(range.to); } + if (!moment.isMoment(range.from) && !moment.isMoment(range.to)) { + return formatDate(dateMath.parse(range.from, true)) + ' to ' + formatDate(dateMath.parse(range.to, true)); + } + var res = describeTextRange(range.from); return res.display; } From a7deca1df54282b64d0f97434861c12db2ae8ccc Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 11 Nov 2015 14:06:47 +0900 Subject: [PATCH 06/10] sort regions by alphabetical order --- pkg/api/cloudwatch/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 1357fccb127..4dbc86c420d 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -69,8 +69,8 @@ func init() { // Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ - "us-east-1", "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1", - "ap-southeast-2", "ap-northeast-1", "sa-east-1", "cn-north-1", + "ap-northeast-1", "ap-southeast-1", "ap-southeast-2", "cn-north-1", + "eu-central-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2", } result := []interface{}{} From 02a37d670cd234b537ef3c46ac0c28f968fbd1b2 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 11 Nov 2015 14:15:20 +0900 Subject: [PATCH 07/10] sort namespaces by alphabetical order --- pkg/api/cloudwatch/metrics.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 4dbc86c420d..813dc9d0b89 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -2,6 +2,7 @@ package cloudwatch import ( "encoding/json" + "sort" "github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/util" @@ -82,8 +83,14 @@ func handleGetRegions(req *cwRequest, c *middleware.Context) { } func handleGetNamespaces(req *cwRequest, c *middleware.Context) { - result := []interface{}{} + keys := []string{} for key := range metricsMap { + keys = append(keys, key) + } + sort.Sort(sort.StringSlice(keys)) + + result := []interface{}{} + for _, key := range keys { result = append(result, util.DynMap{"text": key, "value": key}) } From 509c3dc715b89c3599d464cdf353931a0544ffbb Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 11 Nov 2015 01:34:24 -0800 Subject: [PATCH 08/10] Fixed time range when using NOW from and to --- public/app/core/utils/rangeutil.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 3fc4252ceaf..dda67725208 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -133,12 +133,12 @@ _.each(rangeOptions, function (frame) { return from.fromNow() + ' to ' + formatDate(range.to); } - if (!moment.isMoment(range.from) && !moment.isMoment(range.to)) { - return formatDate(dateMath.parse(range.from, true)) + ' to ' + formatDate(dateMath.parse(range.to, true)); + if (range.to.toString() === 'now') { + var res = describeTextRange(range.from); + return res.display; } - var res = describeTextRange(range.from); - return res.display; + return range.from.toString() + ' to ' + range.to.toString(); } export = { From 9f17e4ee2cf1aa34b27395e7d60f928251d576ea Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 11 Nov 2015 01:34:53 -0800 Subject: [PATCH 09/10] Added unit tests to verify time range fix --- public/test/specs/core/utils/rangeutil_specs.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/test/specs/core/utils/rangeutil_specs.ts b/public/test/specs/core/utils/rangeutil_specs.ts index 8816a15f73d..32286764c20 100644 --- a/public/test/specs/core/utils/rangeutil_specs.ts +++ b/public/test/specs/core/utils/rangeutil_specs.ts @@ -80,6 +80,22 @@ describe("rangeUtil", () => { var text = rangeUtil.describeTimeRange({from: 'now-13h', to: 'now'}); expect(text).to.be('Last 13 hours') }); + + it('Date range with from and to both are in now-* format', () => { + var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now-3h'}); + expect(text).to.be('now-6h to now-3h') + }); + + it('Date range with from and to both are either in now-* or now/* format', () => { + var text = rangeUtil.describeTimeRange({from: 'now/d+6h', to: 'now-3h'}); + expect(text).to.be('now/d+6h to now-3h') + }); + + it('Date range with from and to both are either in now-* or now+* format', () => { + var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now+1h'}); + expect(text).to.be('now-6h to now+1h') + }); + }); }); From cc80191cd176e65a681bd74be1359e0536a70e87 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 11 Nov 2015 19:04:51 +0900 Subject: [PATCH 10/10] CloudWatch ebs templating fix --- public/app/plugins/datasource/cloudwatch/datasource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/cloudwatch/datasource.js b/public/app/plugins/datasource/cloudwatch/datasource.js index 576fb9ffcdd..b2d761bef3c 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -204,7 +204,7 @@ function (angular, _) { return this.performEC2DescribeInstances(region, [], instanceIds).then(function(result) { var volumeIds = _.map(result.Reservations[0].Instances[0].BlockDeviceMappings, function(mapping) { - return mapping.EBS.VolumeID; + return mapping.Ebs.VolumeId; }); return transformSuggestData(volumeIds);