Add top N and bottom N filter functions, closes #241.

This commit is contained in:
Alexander Zobnin
2016-09-24 12:44:22 +03:00
parent dfbcce9c8f
commit aa882d752e
4 changed files with 82 additions and 1 deletions

View File

@@ -92,7 +92,11 @@ export class ZabbixAPIDatasource {
_.forEach(target.functions, func => {
func.params = _.map(func.params, param => {
return this.templateSrv.replace(param, options.scopedVars);
if (typeof param === 'number') {
return +this.templateSrv.replace(param.toString(), options.scopedVars);
} else {
return this.templateSrv.replace(param, options.scopedVars);
}
});
});
@@ -181,6 +185,7 @@ export class ZabbixAPIDatasource {
return getHistory.then(timeseries_data => {
let transformFunctions = bindFunctionDefs(target.functions, 'Transform');
let aggregationFunctions = bindFunctionDefs(target.functions, 'Aggregate');
let filterFunctions = bindFunctionDefs(target.functions, 'Filter');
let aliasFunctions = bindFunctionDefs(target.functions, 'Alias');
// Apply transformation functions
@@ -189,6 +194,11 @@ export class ZabbixAPIDatasource {
return timeseries;
});
// Apply filter functions
if (filterFunctions.length) {
timeseries_data = sequence(filterFunctions)(timeseries_data);
}
// Apply aggregations
if (aggregationFunctions.length) {
let dp = _.map(timeseries_data, 'datapoints');