mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #3249 from mtanda/cloudwatch_null_pointmode
(cloudwatch) support null point mode
This commit is contained in:
commit
e008473e47
@ -25,6 +25,7 @@ function (angular, _) {
|
|||||||
var end = convertToCloudWatchTime(options.range.to);
|
var end = convertToCloudWatchTime(options.range.to);
|
||||||
|
|
||||||
var queries = [];
|
var queries = [];
|
||||||
|
options = _.clone(options);
|
||||||
_.each(options.targets, _.bind(function(target) {
|
_.each(options.targets, _.bind(function(target) {
|
||||||
if (target.hide || !target.namespace || !target.metricName || _.isEmpty(target.statistics)) {
|
if (target.hide || !target.namespace || !target.metricName || _.isEmpty(target.statistics)) {
|
||||||
return;
|
return;
|
||||||
@ -38,11 +39,11 @@ function (angular, _) {
|
|||||||
query.statistics = target.statistics;
|
query.statistics = target.statistics;
|
||||||
|
|
||||||
var range = end - start;
|
var range = end - start;
|
||||||
query.period = parseInt(target.period, 10) || 60;
|
query.period = parseInt(target.period, 10) || (query.namespace === 'AWS/EC2' ? 300 : 60);
|
||||||
|
|
||||||
if (range / query.period >= 1440) {
|
if (range / query.period >= 1440) {
|
||||||
query.period = Math.ceil(range / 1440 / 60) * 60;
|
query.period = Math.ceil(range / 1440 / 60) * 60;
|
||||||
}
|
}
|
||||||
|
target.period = query.period;
|
||||||
|
|
||||||
queries.push(query);
|
queries.push(query);
|
||||||
}, this));
|
}, this));
|
||||||
@ -252,13 +253,22 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
_.extend(aliasData, options.dimensions);
|
_.extend(aliasData, options.dimensions);
|
||||||
|
|
||||||
|
var periodMs = options.period * 1000;
|
||||||
return _.map(options.statistics, function(stat) {
|
return _.map(options.statistics, function(stat) {
|
||||||
var dps = _.chain(md.Datapoints).map(function(dp) {
|
var dps = [];
|
||||||
return [dp[stat], new Date(dp.Timestamp).getTime()];
|
var lastTimestamp = null;
|
||||||
})
|
_.chain(md.Datapoints)
|
||||||
.sortBy(function(dp) {
|
.sortBy(function(dp) {
|
||||||
return dp[1];
|
return dp.Timestamp;
|
||||||
}).value();
|
})
|
||||||
|
.each(function(dp) {
|
||||||
|
var timestamp = new Date(dp.Timestamp).getTime();
|
||||||
|
if (lastTimestamp && (timestamp - lastTimestamp) > periodMs * 2) {
|
||||||
|
dps.push([null, lastTimestamp + periodMs]);
|
||||||
|
}
|
||||||
|
lastTimestamp = timestamp;
|
||||||
|
dps.push([dp[stat], timestamp]);
|
||||||
|
});
|
||||||
|
|
||||||
aliasData.stat = stat;
|
aliasData.stat = stat;
|
||||||
var seriesName = aliasPattern.replace(aliasRegex, function(match, g1) {
|
var seriesName = aliasPattern.replace(aliasRegex, function(match, g1) {
|
||||||
|
@ -48,6 +48,14 @@ describe('CloudWatchDatasource', function() {
|
|||||||
{
|
{
|
||||||
Average: 1,
|
Average: 1,
|
||||||
Timestamp: 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)'
|
Timestamp: 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Average: 2,
|
||||||
|
Timestamp: 'Wed Dec 31 1969 16:05:00 GMT-0800 (PST)'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Average: 5,
|
||||||
|
Timestamp: 'Wed Dec 31 1969 16:20:00 GMT-0800 (PST)'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
Label: 'CPUUtilization'
|
Label: 'CPUUtilization'
|
||||||
@ -82,6 +90,14 @@ describe('CloudWatchDatasource', function() {
|
|||||||
});
|
});
|
||||||
ctx.$rootScope.$apply();
|
ctx.$rootScope.$apply();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return null for missing data point', function(done) {
|
||||||
|
ctx.ds.query(query).then(function(result) {
|
||||||
|
expect(result.data[0].datapoints[2][0]).to.be(null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
ctx.$rootScope.$apply();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function describeMetricFindQuery(query, func) {
|
function describeMetricFindQuery(query, func) {
|
||||||
|
Loading…
Reference in New Issue
Block a user