mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix cloudwatch annotation, reflect API change
This commit is contained in:
parent
79c8556927
commit
e22e20fa9d
@ -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 = {
|
||||
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 = {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user