Просмотр исходного кода

Merge pull request #3445 from mtanda/cloudwatch_sum_period

(cloudwatch) add "Divide Sum By Period" option
Carl Bergquist 10 лет назад
Родитель
Сommit
d465c445fc

+ 3 - 0
public/app/plugins/datasource/cloudwatch/datasource.js

@@ -330,6 +330,9 @@ function (angular, _, moment, dateMath) {
             dps.push([null, lastTimestamp + periodMs]);
           }
           lastTimestamp = timestamp;
+          if (options.divideSumByPeriod && stat === 'Sum') {
+            dp[stat] = dp[stat] / options.period;
+          }
           dps.push([dp[stat], timestamp]);
         });
 

+ 3 - 0
public/app/plugins/datasource/cloudwatch/partials/query.parameter.html

@@ -52,6 +52,9 @@
 		<li>
 			<input type="text" class="input-xlarge tight-form-input"  ng-model="target.alias" spellcheck='false' ng-model-onblur ng-change="onChange()">
 		</li>
+		<li class="tight-form-item query-keyword">
+			Sum / Period <editor-checkbox text="" model="target.divideSumByPeriod" change="onChange()"></editor-checkbox>
+		</li>
 	</ul>
 	<div class="clearfix"></div>
 </div>

+ 1 - 0
public/app/plugins/datasource/cloudwatch/query_ctrl.js

@@ -10,6 +10,7 @@ function (angular, _) {
   module.controller('CloudWatchQueryCtrl', function($scope) {
 
     $scope.init = function() {
+      $scope.target.divideSumByPeriod = $scope.target.divideSumByPeriod || false;
       $scope.aliasSyntax = '{{metric}} {{stat}} {{namespace}} {{region}} {{<dimension name>}}';
     };