فهرست منبع

fix cloudwatch annotation, reflect API change

Mitsuhiro Tanda 10 سال پیش
والد
کامیت
e22e20fa9d

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

@@ -226,7 +226,8 @@ function (angular, _, moment, dateMath) {
       });
       });
     };
     };
 
 
-    CloudWatchDatasource.prototype.annotationQuery = function(annotation, range) {
+    CloudWatchDatasource.prototype.annotationQuery = function(options) {
+      var annotation = options.annotation;
       var region = templateSrv.replace(annotation.region);
       var region = templateSrv.replace(annotation.region);
       var namespace = templateSrv.replace(annotation.namespace);
       var namespace = templateSrv.replace(annotation.namespace);
       var metricName = templateSrv.replace(annotation.metricName);
       var metricName = templateSrv.replace(annotation.metricName);
@@ -254,8 +255,8 @@ function (angular, _, moment, dateMath) {
       this.performDescribeAlarmsForMetric(region, namespace, metricName, dimensions, statistic, period).then(function(alarms) {
       this.performDescribeAlarmsForMetric(region, namespace, metricName, dimensions, statistic, period).then(function(alarms) {
         var eventList = [];
         var eventList = [];
 
 
-        var start = convertToCloudWatchTime(range.from, false);
-        var end = convertToCloudWatchTime(range.to, true);
+        var start = convertToCloudWatchTime(options.range.from, false);
+        var end = convertToCloudWatchTime(options.range.to, true);
         _.each(alarms.MetricAlarms, function(alarm) {
         _.each(alarms.MetricAlarms, function(alarm) {
           self.performDescribeAlarmHistory(region, alarm.AlarmName, start, end).then(function(history) {
           self.performDescribeAlarmHistory(region, alarm.AlarmName, start, end).then(function(history) {
             _.each(history.AlarmHistoryItems, function(h) {
             _.each(history.AlarmHistoryItems, function(h) {

+ 12 - 6
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts

@@ -191,11 +191,17 @@ describe('CloudWatchDatasource', function() {
   });
   });
 
 
   describe('When performing annotationQuery', function() {
   describe('When performing annotationQuery', function() {
-    var annotation = {
-      region: 'us-east-1',
-      namespace: 'AWS/EC2',
-      metricName: 'CPUUtilization',
-      dimensions: 'InstanceId=i-12345678'
+    var parameter = {
+      annotation: {
+        region: 'us-east-1',
+        namespace: 'AWS/EC2',
+        metricName: 'CPUUtilization',
+        dimensions: 'InstanceId=i-12345678'
+      },
+      range: {
+        from: moment(1443438674760),
+        to: moment(1443460274760)
+      }
     };
     };
     var alarmResponse = {
     var alarmResponse = {
       MetricAlarms: [
       MetricAlarms: [
@@ -228,7 +234,7 @@ describe('CloudWatchDatasource', function() {
       };
       };
     });
     });
     it('should return annotation list', function(done) {
     it('should return annotation list', function(done) {
-      ctx.ds.annotationQuery(annotation, {from: moment(1443438674760), to: moment(1443460274760)}).then(function(result) {
+      ctx.ds.annotationQuery(parameter).then(function(result) {
         expect(result[0].title).to.be('test_alarm_name');
         expect(result[0].title).to.be('test_alarm_name');
         expect(result[0].text).to.be('test_history_summary');
         expect(result[0].text).to.be('test_history_summary');
         done();
         done();