Commit e22e20fa by Mitsuhiro Tanda

fix cloudwatch annotation, reflect API change

parent 79c85569
......@@ -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 namespace = templateSrv.replace(annotation.namespace);
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) {
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) {
self.performDescribeAlarmHistory(region, alarm.AlarmName, start, end).then(function(history) {
_.each(history.AlarmHistoryItems, function(h) {
......
......@@ -191,11 +191,17 @@ describe('CloudWatchDatasource', function() {
});
describe('When performing annotationQuery', function() {
var annotation = {
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 = {
MetricAlarms: [
......@@ -228,7 +234,7 @@ describe('CloudWatchDatasource', function() {
};
});
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].text).to.be('test_history_summary');
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