Able to specify trend value (min, max or avg by default).

This commit is contained in:
Alexander Zobnin
2016-02-05 12:11:23 +03:00
parent 5a77fafc61
commit 16a7786247
2 changed files with 19 additions and 3 deletions

View File

@@ -132,12 +132,18 @@ function (angular, _, dateMath, utils, metricFunctions) {
.then(function(items) {
// Add hostname for items from multiple hosts
var addHostName = target.host.isRegex;
var getHistory;
if ((from < useTrendsFrom) && self.trends) {
// Use trends
var valueType = target.downsampleFunction ? target.downsampleFunction.value : "avg";
if ((from < useTrendsFrom) && self.trends) {
// Find trendValue() function and get specified trend value
var trendFunctions = _.map(metricFunctions.getCategories()['Trends'], 'name');
var trendValueFunc = _.find(target.functions, function(func) {
return _.contains(trendFunctions, func.def.name);
});
var valueType = trendValueFunc ? trendValueFunc.params[0] : "avg";
getHistory = self.zabbixAPI.getTrend(items, from, to).then(function(history) {
return self.queryProcessor.handleTrends(history, addHostName, valueType);
});

View File

@@ -9,6 +9,7 @@ function (_, $) {
var categories = {
Transform: [],
Aggregate: [],
Trends: [],
Alias: []
};
@@ -76,6 +77,15 @@ function (_, $) {
defaultParams: ['1m'],
});
addFuncDef({
name: 'trendValue',
category: 'Trends',
params: [
{ name: 'type', type: 'string', options: ['avg', 'min', 'max'] }
],
defaultParams: ['avg'],
});
addFuncDef({
name: 'setAlias',
category: 'Alias',