mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Update check for invalid percentile statistics
This commit is contained in:
parent
bcdda7b9ad
commit
58a156ba03
@ -44,7 +44,13 @@ export default class CloudWatchDatasource {
|
|||||||
|
|
||||||
// valid ExtendedStatistics is like p90.00, check the pattern
|
// valid ExtendedStatistics is like p90.00, check the pattern
|
||||||
const hasInvalidStatistics = item.statistics.some(s => {
|
const hasInvalidStatistics = item.statistics.some(s => {
|
||||||
return s.indexOf('p') === 0 && !/p\d{2}\.\d{2}/.test(s);
|
if (s.indexOf('p') === 0) {
|
||||||
|
const matches = /^p\d{2}(?:\.\d{1,2})?$/.exec(s);
|
||||||
|
|
||||||
|
return !matches || matches[0] !== s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
if (hasInvalidStatistics) {
|
if (hasInvalidStatistics) {
|
||||||
throw { message: 'Invalid extended statistics' };
|
throw { message: 'Invalid extended statistics' };
|
||||||
|
@ -122,7 +122,7 @@ describe('CloudWatchDatasource', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cancel query for invalid extended statistics', () => {
|
it.each(['pNN.NN', 'p9', 'p99.', 'p99.999'])('should cancel query for invalid extended statistics (%s)', stat => {
|
||||||
const query = {
|
const query = {
|
||||||
range: { from: 'now-1h', to: 'now' },
|
range: { from: 'now-1h', to: 'now' },
|
||||||
rangeRaw: { from: 1483228800, to: 1483232400 },
|
rangeRaw: { from: 1483228800, to: 1483232400 },
|
||||||
@ -134,7 +134,7 @@ describe('CloudWatchDatasource', () => {
|
|||||||
dimensions: {
|
dimensions: {
|
||||||
InstanceId: 'i-12345678',
|
InstanceId: 'i-12345678',
|
||||||
},
|
},
|
||||||
statistics: ['pNN.NN'],
|
statistics: [stat],
|
||||||
period: '60s',
|
period: '60s',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user