Add top N and bottom N filter functions, closes #241.
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user