Merge branch 'pedrohrf-master'
This commit is contained in:
10
dist/datasource-zabbix/dataProcessor.js
vendored
10
dist/datasource-zabbix/dataProcessor.js
vendored
@@ -3,7 +3,7 @@
|
||||
System.register(['lodash', './utils', './timeseries'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils, ts, downsampleSeries, groupBy, groupBy_exported, sumSeries, delta, rate, scale, simpleMovingAverage, expMovingAverage, SUM, COUNT, AVERAGE, MIN, MAX, MEDIAN, metricFunctions, aggregationFunctions;
|
||||
var _, utils, ts, downsampleSeries, groupBy, groupBy_exported, sumSeries, delta, rate, scale, simpleMovingAverage, expMovingAverage, SUM, COUNT, AVERAGE, MIN, MAX, MEDIAN, PERCENTIL, metricFunctions, aggregationFunctions;
|
||||
|
||||
function limit(order, n, orderByFunc, timeseries) {
|
||||
var orderByCallback = aggregationFunctions[orderByFunc];
|
||||
@@ -68,6 +68,12 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function percentil(interval, n, datapoints) {
|
||||
var flattenedPoints = _.flatten(datapoints, true);
|
||||
var groupByCallback = _.partial(PERCENTIL, n);
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function timeShift(interval, range) {
|
||||
var shift = utils.parseTimeShiftInterval(interval) / 1000;
|
||||
return _.map(range, function (time) {
|
||||
@@ -120,6 +126,7 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
MIN = ts.MIN;
|
||||
MAX = ts.MAX;
|
||||
MEDIAN = ts.MEDIAN;
|
||||
PERCENTIL = ts.PERCENTIL;
|
||||
metricFunctions = {
|
||||
groupBy: groupByWrapper,
|
||||
scale: scale,
|
||||
@@ -129,6 +136,7 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentil: percentil,
|
||||
average: _.partial(aggregateWrapper, AVERAGE),
|
||||
min: _.partial(aggregateWrapper, MIN),
|
||||
max: _.partial(aggregateWrapper, MAX),
|
||||
|
||||
2
dist/datasource-zabbix/dataProcessor.js.map
vendored
2
dist/datasource-zabbix/dataProcessor.js.map
vendored
File diff suppressed because one or more lines are too long
7
dist/datasource-zabbix/metricFunctions.js
vendored
7
dist/datasource-zabbix/metricFunctions.js
vendored
@@ -148,6 +148,13 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentil',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'percent', type: 'float', options: [25, 50, 75, 90, 95, 99, 99.9] }],
|
||||
defaultParams: ['1m', 95]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
|
||||
File diff suppressed because one or more lines are too long
8
dist/datasource-zabbix/timeseries.js
vendored
8
dist/datasource-zabbix/timeseries.js
vendored
@@ -305,6 +305,11 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return ema;
|
||||
}
|
||||
|
||||
function PERCENTIL(n, values) {
|
||||
var sorted = _.sortBy(values);
|
||||
return sorted[Math.floor(sorted.length * n / 100)];
|
||||
}
|
||||
|
||||
function COUNT(values) {
|
||||
return values.length;
|
||||
}
|
||||
@@ -474,7 +479,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
AVERAGE: AVERAGE,
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN
|
||||
MEDIAN: MEDIAN,
|
||||
PERCENTIL: PERCENTIL
|
||||
};
|
||||
|
||||
_export('default', exportedFunctions);
|
||||
|
||||
2
dist/datasource-zabbix/timeseries.js.map
vendored
2
dist/datasource-zabbix/timeseries.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/test/datasource-zabbix/dataProcessor.js
vendored
8
dist/test/datasource-zabbix/dataProcessor.js
vendored
@@ -44,6 +44,7 @@ var AVERAGE = _timeseries2.default.AVERAGE;
|
||||
var MIN = _timeseries2.default.MIN;
|
||||
var MAX = _timeseries2.default.MAX;
|
||||
var MEDIAN = _timeseries2.default.MEDIAN;
|
||||
var PERCENTIL = _timeseries2.default.PERCENTIL;
|
||||
|
||||
function limit(order, n, orderByFunc, timeseries) {
|
||||
var orderByCallback = aggregationFunctions[orderByFunc];
|
||||
@@ -108,6 +109,12 @@ function aggregateWrapper(groupByCallback, interval, datapoints) {
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function percentil(interval, n, datapoints) {
|
||||
var flattenedPoints = _lodash2.default.flatten(datapoints, true);
|
||||
var groupByCallback = _lodash2.default.partial(PERCENTIL, n);
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function timeShift(interval, range) {
|
||||
var shift = utils.parseTimeShiftInterval(interval) / 1000;
|
||||
return _lodash2.default.map(range, function (time) {
|
||||
@@ -131,6 +138,7 @@ var metricFunctions = {
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentil: percentil,
|
||||
average: _lodash2.default.partial(aggregateWrapper, AVERAGE),
|
||||
min: _lodash2.default.partial(aggregateWrapper, MIN),
|
||||
max: _lodash2.default.partial(aggregateWrapper, MAX),
|
||||
|
||||
@@ -111,6 +111,13 @@ addFuncDef({
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentil',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'percent', type: 'float', options: [25, 50, 75, 90, 95, 99, 99.9] }],
|
||||
defaultParams: ['1m', 95]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
|
||||
8
dist/test/datasource-zabbix/timeseries.js
vendored
8
dist/test/datasource-zabbix/timeseries.js
vendored
@@ -330,6 +330,11 @@ function expMovingAverage(datapoints, n) {
|
||||
return ema;
|
||||
}
|
||||
|
||||
function PERCENTIL(n, values) {
|
||||
var sorted = _lodash2.default.sortBy(values);
|
||||
return sorted[Math.floor(sorted.length * n / 100)];
|
||||
}
|
||||
|
||||
function COUNT(values) {
|
||||
return values.length;
|
||||
}
|
||||
@@ -490,7 +495,8 @@ var exportedFunctions = {
|
||||
AVERAGE: AVERAGE,
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN
|
||||
MEDIAN: MEDIAN,
|
||||
PERCENTIL: PERCENTIL
|
||||
};
|
||||
|
||||
exports.default = exportedFunctions;
|
||||
|
||||
@@ -18,6 +18,7 @@ let AVERAGE = ts.AVERAGE;
|
||||
let MIN = ts.MIN;
|
||||
let MAX = ts.MAX;
|
||||
let MEDIAN = ts.MEDIAN;
|
||||
let PERCENTIL = ts.PERCENTIL;
|
||||
|
||||
function limit(order, n, orderByFunc, timeseries) {
|
||||
let orderByCallback = aggregationFunctions[orderByFunc];
|
||||
@@ -82,6 +83,12 @@ function aggregateWrapper(groupByCallback, interval, datapoints) {
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function percentil(interval, n, datapoints) {
|
||||
var flattenedPoints = _.flatten(datapoints, true);
|
||||
var groupByCallback = _.partial(PERCENTIL, n);
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function timeShift(interval, range) {
|
||||
let shift = utils.parseTimeShiftInterval(interval) / 1000;
|
||||
return _.map(range, time => {
|
||||
@@ -108,6 +115,7 @@ let metricFunctions = {
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentil: percentil,
|
||||
average: _.partial(aggregateWrapper, AVERAGE),
|
||||
min: _.partial(aggregateWrapper, MIN),
|
||||
max: _.partial(aggregateWrapper, MAX),
|
||||
|
||||
@@ -103,6 +103,16 @@ addFuncDef({
|
||||
defaultParams: ['1m'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentil',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' },
|
||||
{ name: 'percent', type: 'float', options: [25, 50, 75, 90, 95, 99, 99.9] }
|
||||
],
|
||||
defaultParams: ['1m', 95],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
|
||||
@@ -322,6 +322,11 @@ function expMovingAverage(datapoints, n) {
|
||||
return ema;
|
||||
}
|
||||
|
||||
function PERCENTIL(n, values) {
|
||||
var sorted = _.sortBy(values);
|
||||
return sorted[Math.floor(sorted.length * n / 100)];
|
||||
}
|
||||
|
||||
function COUNT(values) {
|
||||
return values.length;
|
||||
}
|
||||
@@ -482,7 +487,8 @@ const exportedFunctions = {
|
||||
AVERAGE,
|
||||
MIN,
|
||||
MAX,
|
||||
MEDIAN
|
||||
MEDIAN,
|
||||
PERCENTIL
|
||||
};
|
||||
|
||||
export default exportedFunctions;
|
||||
|
||||
Reference in New Issue
Block a user