From fdeeb73587180417cd1524cbf8f1cb94c31fedd4 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 4 Nov 2015 02:27:35 -0800 Subject: [PATCH 01/10] AWS Region as a mandatory field --- public/app/plugins/datasource/cloudwatch/partials/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 60c645c33f9..15d747ac937 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -20,7 +20,7 @@ Default RegionSpecify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
  • - +
  • From 4de9ac133a398b4b48585859b0e2cffb10dff916 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 4 Nov 2015 17:21:34 -0800 Subject: [PATCH 02/10] Set default AWS region from dropdown now --- public/app/features/org/datasourceEditCtrl.js | 18 ++++++++++++++++++ .../datasource/cloudwatch/partials/config.html | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/app/features/org/datasourceEditCtrl.js b/public/app/features/org/datasourceEditCtrl.js index 09dd8606092..46b8ab11abc 100644 --- a/public/app/features/org/datasourceEditCtrl.js +++ b/public/app/features/org/datasourceEditCtrl.js @@ -50,16 +50,34 @@ function (angular, config, _) { }); }; + $scope.loadAWSRegions = function() { + var options = { + method: 'POST', + url: '/api/datasources/proxy/' + $scope.current.id, + data: { action: '__GetRegions' } + }; + + return backendSrv.datasourceRequest(options).then(function(result) { + $scope.current.jsonData.allRegions = result.data.map(function(region) { + return region.text; + }); + }); + }; + $scope.getDatasourceById = function(id) { backendSrv.get('/api/datasources/' + id).then(function(ds) { $scope.isNew = false; $scope.current = ds; + console.log($scope.current); $scope.typeChanged(); }); }; $scope.typeChanged = function() { $scope.datasourceMeta = $scope.types[$scope.current.type]; + if ($scope.current.type === 'cloudwatch') { + $scope.loadAWSRegions(); + } }; $scope.updateFrontendSettings = function() { diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 15d747ac937..0d7bf81777f 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -20,7 +20,7 @@ Default RegionSpecify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
  • - +
  • From b678daa744ea78cf4b3928a11080b8fd86aeb30e Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 5 Nov 2015 22:31:33 -0800 Subject: [PATCH 03/10] Added throughput units. --- public/app/components/kbn.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/public/app/components/kbn.js b/public/app/components/kbn.js index ad2d4c3c422..825df91ff3c 100644 --- a/public/app/components/kbn.js +++ b/public/app/components/kbn.js @@ -344,6 +344,12 @@ function($, _) { kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps'); kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps'); + // Throughput + kbn.valueFormats.ops = kbn.formatBuilders.fixedUnit('ops'); + kbn.valueFormats.rps = kbn.formatBuilders.fixedUnit('rps'); + kbn.valueFormats.wps = kbn.formatBuilders.fixedUnit('wps'); + kbn.valueFormats.iops = kbn.formatBuilders.fixedUnit('iops'); + // Energy kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W'); kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix('W', 1); @@ -522,6 +528,15 @@ function($, _) { {text: 'bytes/sec', value: 'Bps'}, ] }, + { + text: 'throughput', + submenu: [ + {text: 'ops/sec (ops)', value: 'ops' }, + {text: 'reads/sec (rps)', value: 'rps' }, + {text: 'writes/sec (wps)', value: 'wps' }, + {text: 'I/O ops/sec (iops)', value: 'iops'}, + ] + }, { text: 'length', submenu: [ @@ -576,7 +591,7 @@ function($, _) { {text: 'Inches of mercury', value: 'pressurehg' }, {text: 'PSI', value: 'pressurepsi' }, ] - }, + } ]; }; From 22c3ec2d638e94c985e40bff3aea6e8515f7841b Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 5 Nov 2015 22:57:05 -0800 Subject: [PATCH 04/10] Made the units more readable --- public/app/components/kbn.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/public/app/components/kbn.js b/public/app/components/kbn.js index 825df91ff3c..34d943ed028 100644 --- a/public/app/components/kbn.js +++ b/public/app/components/kbn.js @@ -310,6 +310,16 @@ function($, _) { }; }; + kbn.formatBuilders.simpleCountUnit = function(symbol) { + var units = ['', 'K', 'M', 'B', 'T']; + var scaler = kbn.formatBuilders.scaledUnits(1000, units); + return function(size, decimals, scaledDecimals) { + if (size === null) { return ""; } + var scaled = scaler(size, decimals, scaledDecimals); + return scaled + " " + symbol; + }; + }; + ///// VALUE FORMATS ///// // Dimensionless Units @@ -345,10 +355,10 @@ function($, _) { kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps'); // Throughput - kbn.valueFormats.ops = kbn.formatBuilders.fixedUnit('ops'); - kbn.valueFormats.rps = kbn.formatBuilders.fixedUnit('rps'); - kbn.valueFormats.wps = kbn.formatBuilders.fixedUnit('wps'); - kbn.valueFormats.iops = kbn.formatBuilders.fixedUnit('iops'); + kbn.valueFormats.ops = kbn.formatBuilders.simpleCountUnit('ops'); + kbn.valueFormats.rps = kbn.formatBuilders.simpleCountUnit('rps'); + kbn.valueFormats.wps = kbn.formatBuilders.simpleCountUnit('wps'); + kbn.valueFormats.iops = kbn.formatBuilders.simpleCountUnit('iops'); // Energy kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W'); From b5f18561ab401a49446d5e46cf334679b94c0b67 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 5 Nov 2015 23:13:53 -0800 Subject: [PATCH 05/10] Added unit tests to verify units --- public/test/specs/kbn-format-specs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/test/specs/kbn-format-specs.js b/public/test/specs/kbn-format-specs.js index f84544fff4f..3e4803633e3 100644 --- a/public/test/specs/kbn-format-specs.js +++ b/public/test/specs/kbn-format-specs.js @@ -62,6 +62,12 @@ define([ describeValueFormat('ns', 25, 1, 0, '25 ns'); describeValueFormat('ns', 2558, 50, 0, '2.56 µs'); + describeValueFormat('ops', 123, 1, 0, '123 ops'); + describeValueFormat('rps', 456000, 1000, -1, '456K rps'); + describeValueFormat('rps', 123456789, 1000000, 2, '123.457M rps'); + describeValueFormat('wps', 789000000, 1000000, -1, '789M wps'); + describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops'); + describe('kbn.toFixed and negative decimals', function() { it('should treat as zero decimals', function() { var str = kbn.toFixed(186.123, -2); From e16bbc660d7bc19e3ae0e81173dcf55817e24e5e Mon Sep 17 00:00:00 2001 From: Don Date: Sat, 7 Nov 2015 00:06:15 -0600 Subject: [PATCH 06/10] use [auth.github] -> api_url property; supports git enterprise --- pkg/social/social.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/social/social.go b/pkg/social/social.go index 1a00934b937..06932f3d500 100644 --- a/pkg/social/social.go +++ b/pkg/social/social.go @@ -193,7 +193,7 @@ func (s *SocialGithub) FetchPrivateEmail(client *http.Client) (string, error) { Verified bool `json:"verified"` } - emailsUrl := fmt.Sprintf("https://api.github.com/user/emails") + emailsUrl := fmt.Sprintf(s.apiUrl + "/emails") r, err := client.Get(emailsUrl) if err != nil { return "", err @@ -222,7 +222,7 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]int, error) Id int `json:"id"` } - membershipUrl := fmt.Sprintf("https://api.github.com/user/teams") + membershipUrl := fmt.Sprintf(s.apiUrl + "/teams") r, err := client.Get(membershipUrl) if err != nil { return nil, err @@ -249,7 +249,7 @@ func (s *SocialGithub) FetchOrganizations(client *http.Client) ([]string, error) Login string `json:"login"` } - url := fmt.Sprintf("https://api.github.com/user/orgs") + url := fmt.Sprintf(s.apiUrl + "/orgs") r, err := client.Get(url) if err != nil { return nil, err From b345c7cf461a3647ab8d0e376dc6d959a75084f8 Mon Sep 17 00:00:00 2001 From: Don Thapa Date: Sat, 7 Nov 2015 11:32:06 -0600 Subject: [PATCH 07/10] gofmt happiness --- pkg/social/social.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/social/social.go b/pkg/social/social.go index 06932f3d500..4a8cb8bac5d 100644 --- a/pkg/social/social.go +++ b/pkg/social/social.go @@ -222,7 +222,7 @@ func (s *SocialGithub) FetchTeamMemberships(client *http.Client) ([]int, error) Id int `json:"id"` } - membershipUrl := fmt.Sprintf(s.apiUrl + "/teams") + membershipUrl := fmt.Sprintf(s.apiUrl + "/teams") r, err := client.Get(membershipUrl) if err != nil { return nil, err From 9f066d01b1cf368bb71783532046cbfb4d1684a5 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 9 Nov 2015 03:35:51 -0800 Subject: [PATCH 08/10] Check specified AWS Region and not us-east-1 --- 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..6847d714975 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -216,7 +216,7 @@ function (angular, _) { CloudWatchDatasource.prototype.testDatasource = function() { /* use billing metrics for test */ - var region = 'us-east-1'; + var region = this.defaultRegion; var namespace = 'AWS/Billing'; var metricName = 'EstimatedCharges'; var dimensions = {}; From 7612e47aee5424bdca82ec7a7d9b63921b5f607d Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 9 Nov 2015 12:08:40 -0800 Subject: [PATCH 09/10] Select AWS region from dropdown --- pkg/api/cloudwatch/metrics.go | 2 ++ public/app/features/org/datasourceEditCtrl.js | 18 ------------------ .../datasource/cloudwatch/partials/config.html | 9 +++++++-- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 6d6ff10dfb9..ab4df6784c7 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -65,6 +65,8 @@ func init() { } } +// Whenever this list is updated, frontend list should also be updated. +// Please update the region list in public/app/features/org/datasourceEditCtrl.js func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1", diff --git a/public/app/features/org/datasourceEditCtrl.js b/public/app/features/org/datasourceEditCtrl.js index 46b8ab11abc..09dd8606092 100644 --- a/public/app/features/org/datasourceEditCtrl.js +++ b/public/app/features/org/datasourceEditCtrl.js @@ -50,34 +50,16 @@ function (angular, config, _) { }); }; - $scope.loadAWSRegions = function() { - var options = { - method: 'POST', - url: '/api/datasources/proxy/' + $scope.current.id, - data: { action: '__GetRegions' } - }; - - return backendSrv.datasourceRequest(options).then(function(result) { - $scope.current.jsonData.allRegions = result.data.map(function(region) { - return region.text; - }); - }); - }; - $scope.getDatasourceById = function(id) { backendSrv.get('/api/datasources/' + id).then(function(ds) { $scope.isNew = false; $scope.current = ds; - console.log($scope.current); $scope.typeChanged(); }); }; $scope.typeChanged = function() { $scope.datasourceMeta = $scope.types[$scope.current.type]; - if ($scope.current.type === 'cloudwatch') { - $scope.loadAWSRegions(); - } }; $scope.updateFrontendSettings = function() { diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 0d7bf81777f..311ca0ae3dc 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -19,8 +19,13 @@
  • Default RegionSpecify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
  • -
  • - + +
  • +
  • From 6325635fce4159d632ef21c75ba9bf4eb46b3bb4 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 9 Nov 2015 12:31:35 -0800 Subject: [PATCH 10/10] Corrected the frontend filename --- pkg/api/cloudwatch/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index ab4df6784c7..a5e738a2ae9 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -66,7 +66,7 @@ func init() { } // Whenever this list is updated, frontend list should also be updated. -// Please update the region list in public/app/features/org/datasourceEditCtrl.js +// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1",