Fix tests after merging alerting
This commit is contained in:
16
dist/datasource-zabbix/dataProcessor.js
vendored
16
dist/datasource-zabbix/dataProcessor.js
vendored
@@ -126,6 +126,14 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
} else {
|
||||
return sortedTimeseries.slice(-n);
|
||||
}
|
||||
}function SUM(values) {
|
||||
var sum = 0;
|
||||
_.each(values, function (value) {
|
||||
sum += value;
|
||||
});
|
||||
return sum;
|
||||
}function COUNT(values) {
|
||||
return values.length;
|
||||
}function AVERAGE(values) {
|
||||
var sum = 0;
|
||||
_.each(values, function (value) {
|
||||
@@ -250,6 +258,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
min: _.partial(aggregateWrapper, MIN),
|
||||
max: _.partial(aggregateWrapper, MAX),
|
||||
median: _.partial(aggregateWrapper, MEDIAN),
|
||||
sum: _.partial(aggregateWrapper, SUM),
|
||||
count: _.partial(aggregateWrapper, COUNT),
|
||||
sumSeries: sumSeries,
|
||||
top: _.partial(limit, 'top'),
|
||||
bottom: _.partial(limit, 'bottom'),
|
||||
@@ -261,7 +271,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
avg: AVERAGE,
|
||||
min: MIN,
|
||||
max: MAX,
|
||||
median: MEDIAN
|
||||
median: MEDIAN,
|
||||
sum: SUM,
|
||||
count: COUNT
|
||||
};
|
||||
|
||||
_export('default', {
|
||||
@@ -271,6 +283,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN,
|
||||
SUM: SUM,
|
||||
COUNT: COUNT,
|
||||
unShiftTimeSeries: unShiftTimeSeries,
|
||||
|
||||
get aggregationFunctions() {
|
||||
|
||||
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
24
dist/datasource-zabbix/metricFunctions.js
vendored
24
dist/datasource-zabbix/metricFunctions.js
vendored
@@ -85,7 +85,7 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
addFuncDef({
|
||||
name: 'groupBy',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
@@ -140,10 +140,24 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sum',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'count',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'aggregateBy',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
@@ -152,14 +166,14 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
addFuncDef({
|
||||
name: 'top',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'bottom',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
@@ -168,7 +182,7 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
addFuncDef({
|
||||
name: 'trendValue',
|
||||
category: 'Trends',
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max'] }],
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count'] }],
|
||||
defaultParams: ['avg']
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
dist/datasource-zabbix/query.controller.js
vendored
2
dist/datasource-zabbix/query.controller.js
vendored
@@ -139,7 +139,7 @@ System.register(['app/plugins/sdk', 'angular', 'lodash', './utils', './metricFun
|
||||
|
||||
if (target.mode === 0 || target.mode === 2) {
|
||||
|
||||
this.downsampleFunctionList = [{ name: "avg", value: "avg" }, { name: "min", value: "min" }, { name: "max", value: "max" }];
|
||||
this.downsampleFunctionList = [{ name: "avg", value: "avg" }, { name: "min", value: "min" }, { name: "max", value: "max" }, { name: "sum", value: "sum" }, { name: "count", value: "count" }];
|
||||
|
||||
this.initFilters();
|
||||
} else if (target.mode === 1) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
dist/datasource-zabbix/responseHandler.js
vendored
6
dist/datasource-zabbix/responseHandler.js
vendored
@@ -86,6 +86,12 @@ System.register(['lodash'], function (_export, _context) {
|
||||
case "avg":
|
||||
value = point.value_avg;
|
||||
break;
|
||||
case "sum":
|
||||
value = point.value_sum;
|
||||
break;
|
||||
case "count":
|
||||
value = point.value_count;
|
||||
break;
|
||||
default:
|
||||
value = point.value_avg;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,9 +20,10 @@ describe('ZabbixDatasource', () => {
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.zabbixAlertingSrv = {};
|
||||
ctx.zabbix = () => {};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbix);
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
});
|
||||
|
||||
|
||||
20
dist/test/datasource-zabbix/dataProcessor.js
vendored
20
dist/test/datasource-zabbix/dataProcessor.js
vendored
@@ -143,6 +143,18 @@ function limit(order, n, orderByFunc, timeseries) {
|
||||
}
|
||||
}
|
||||
|
||||
function SUM(values) {
|
||||
var sum = 0;
|
||||
_lodash2.default.each(values, function (value) {
|
||||
sum += value;
|
||||
});
|
||||
return sum;
|
||||
}
|
||||
|
||||
function COUNT(values) {
|
||||
return values.length;
|
||||
}
|
||||
|
||||
function AVERAGE(values) {
|
||||
var sum = 0;
|
||||
_lodash2.default.each(values, function (value) {
|
||||
@@ -296,6 +308,8 @@ var metricFunctions = {
|
||||
min: _lodash2.default.partial(aggregateWrapper, MIN),
|
||||
max: _lodash2.default.partial(aggregateWrapper, MAX),
|
||||
median: _lodash2.default.partial(aggregateWrapper, MEDIAN),
|
||||
sum: _lodash2.default.partial(aggregateWrapper, SUM),
|
||||
count: _lodash2.default.partial(aggregateWrapper, COUNT),
|
||||
sumSeries: sumSeries,
|
||||
top: _lodash2.default.partial(limit, 'top'),
|
||||
bottom: _lodash2.default.partial(limit, 'bottom'),
|
||||
@@ -308,7 +322,9 @@ var aggregationFunctions = {
|
||||
avg: AVERAGE,
|
||||
min: MIN,
|
||||
max: MAX,
|
||||
median: MEDIAN
|
||||
median: MEDIAN,
|
||||
sum: SUM,
|
||||
count: COUNT
|
||||
};
|
||||
|
||||
exports.default = {
|
||||
@@ -318,6 +334,8 @@ exports.default = {
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN,
|
||||
SUM: SUM,
|
||||
COUNT: COUNT,
|
||||
unShiftTimeSeries: unShiftTimeSeries,
|
||||
|
||||
get aggregationFunctions() {
|
||||
|
||||
24
dist/test/datasource-zabbix/metricFunctions.js
vendored
24
dist/test/datasource-zabbix/metricFunctions.js
vendored
@@ -48,7 +48,7 @@ function addFuncDef(funcDef) {
|
||||
addFuncDef({
|
||||
name: 'groupBy',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
@@ -103,10 +103,24 @@ addFuncDef({
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sum',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'count',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'aggregateBy',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
@@ -115,14 +129,14 @@ addFuncDef({
|
||||
addFuncDef({
|
||||
name: 'top',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'bottom',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'median'] }],
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
@@ -131,7 +145,7 @@ addFuncDef({
|
||||
addFuncDef({
|
||||
name: 'trendValue',
|
||||
category: 'Trends',
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max'] }],
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count'] }],
|
||||
defaultParams: ['avg']
|
||||
});
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
|
||||
if (target.mode === 0 || target.mode === 2) {
|
||||
|
||||
this.downsampleFunctionList = [{ name: "avg", value: "avg" }, { name: "min", value: "min" }, { name: "max", value: "max" }];
|
||||
this.downsampleFunctionList = [{ name: "avg", value: "avg" }, { name: "min", value: "min" }, { name: "max", value: "max" }, { name: "sum", value: "sum" }, { name: "count", value: "count" }];
|
||||
|
||||
this.initFilters();
|
||||
} else if (target.mode === 1) {
|
||||
|
||||
@@ -95,6 +95,12 @@ function convertTrendPoint(valueType, point) {
|
||||
case "avg":
|
||||
value = point.value_avg;
|
||||
break;
|
||||
case "sum":
|
||||
value = point.value_sum;
|
||||
break;
|
||||
case "count":
|
||||
value = point.value_count;
|
||||
break;
|
||||
default:
|
||||
value = point.value_avg;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,10 @@ describe('ZabbixDatasource', function () {
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.zabbixAlertingSrv = {};
|
||||
ctx.zabbix = function () {};
|
||||
|
||||
ctx.ds = new _module.Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbix);
|
||||
ctx.ds = new _module.Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
ctx.ds.alertQuery = function () {
|
||||
return _q2.default.when([]);
|
||||
};
|
||||
|
||||
@@ -20,9 +20,10 @@ describe('ZabbixDatasource', () => {
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.zabbixAlertingSrv = {};
|
||||
ctx.zabbix = () => {};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbix);
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user