Commit 9b50c903 by Mitsuhiro Tanda Committed by Torkel Ödegaard

skip backend request if extended statistics is invalid. (#12495)

* check extended statistics pattern

* check extended statistics pattern

* Revert "check extended statistics pattern"

This reverts commit 52c7b1a972636d5f5729e64ae5e00e6fae329257.

* add test

* fix test
parent c03764ff
......@@ -39,6 +39,14 @@ export default class CloudWatchDatasource {
item.dimensions = this.convertDimensionFormat(item.dimensions, options.scopedVars);
item.period = String(this.getPeriod(item, options)); // use string format for period in graph query, and alerting
// valid ExtendedStatistics is like p90.00, check the pattern
let hasInvalidStatistics = item.statistics.some(s => {
return s.indexOf('p') === 0 && !/p\d{2}\.\d{2}/.test(s);
});
if (hasInvalidStatistics) {
throw { message: 'Invalid extended statistics' };
}
return _.extend(
{
refId: item.refId,
......
......@@ -121,6 +121,26 @@ describe('CloudWatchDatasource', function() {
});
});
it('should cancel query for invalid extended statistics', function () {
var query = {
range: { from: 'now-1h', to: 'now' },
rangeRaw: { from: 1483228800, to: 1483232400 },
targets: [
{
region: 'us-east-1',
namespace: 'AWS/EC2',
metricName: 'CPUUtilization',
dimensions: {
InstanceId: 'i-12345678',
},
statistics: ['pNN.NN'],
period: '60s',
},
],
};
expect(ctx.ds.query.bind(ctx.ds, query)).toThrow(/Invalid extended statistics/);
});
it('should return series list', function(done) {
ctx.ds.query(query).then(function(result) {
expect(result.data[0].target).toBe(response.results.A.series[0].name);
......
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