Commit e22e20fa by Mitsuhiro Tanda

fix cloudwatch annotation, reflect API change

parent 79c85569
...@@ -226,7 +226,8 @@ function (angular, _, moment, dateMath) { ...@@ -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) { ...@@ -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 start = convertToCloudWatchTime(options.range.from, false);
var end = convertToCloudWatchTime(range.to, true); 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) {
......
...@@ -191,11 +191,17 @@ describe('CloudWatchDatasource', function() { ...@@ -191,11 +191,17 @@ describe('CloudWatchDatasource', function() {
}); });
describe('When performing annotationQuery', function() { describe('When performing annotationQuery', function() {
var annotation = { var parameter = {
region: 'us-east-1', annotation: {
namespace: 'AWS/EC2', region: 'us-east-1',
metricName: 'CPUUtilization', namespace: 'AWS/EC2',
dimensions: 'InstanceId=i-12345678' 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() { ...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment