Able to specify trend value (min, max or avg by default).
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user