Merge branch 'develop'
This commit is contained in:
@@ -142,6 +142,15 @@ export default class DataProcessor {
|
||||
return timeseries;
|
||||
}
|
||||
|
||||
static scale(factor, datapoints) {
|
||||
return _.map(datapoints, point => {
|
||||
return [
|
||||
point[0] * factor,
|
||||
point[1]
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
static groupByWrapper(interval, groupFunc, datapoints) {
|
||||
var groupByCallback = DataProcessor.aggregationFunctions[groupFunc];
|
||||
return DataProcessor.groupBy(interval, groupByCallback, datapoints);
|
||||
@@ -171,6 +180,7 @@ export default class DataProcessor {
|
||||
static get metricFunctions() {
|
||||
return {
|
||||
groupBy: this.groupByWrapper,
|
||||
scale: this.scale,
|
||||
aggregateBy: this.aggregateByWrapper,
|
||||
average: _.partial(this.aggregateWrapper, this.AVERAGE),
|
||||
min: _.partial(this.aggregateWrapper, this.MIN),
|
||||
@@ -223,7 +233,7 @@ function findNearestRight(series, point) {
|
||||
var point_index = _.indexOf(series, point);
|
||||
var nearestRight;
|
||||
for (var i = point_index; i < series.length; i++) {
|
||||
if (series[i][0]) {
|
||||
if (series[i][0] !== null) {
|
||||
return series[i];
|
||||
}
|
||||
}
|
||||
@@ -234,7 +244,7 @@ function findNearestLeft(series, point) {
|
||||
var point_index = _.indexOf(series, point);
|
||||
var nearestLeft;
|
||||
for (var i = point_index; i > 0; i--) {
|
||||
if (series[i][0]) {
|
||||
if (series[i][0] !== null) {
|
||||
return series[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,10 +176,10 @@ export class ZabbixAPIDatasource {
|
||||
// Apply transformation functions
|
||||
timeseries_data = _.map(timeseries_data, timeseries => {
|
||||
|
||||
// Filter only transform functions
|
||||
// Filter only transformation functions
|
||||
var transformFunctions = bindFunctionDefs(target.functions, 'Transform', DataProcessor);
|
||||
|
||||
// Metric data processing
|
||||
// Timeseries processing
|
||||
var dp = timeseries.datapoints;
|
||||
for (var i = 0; i < transformFunctions.length; i++) {
|
||||
dp = transformFunctions[i](dp);
|
||||
@@ -492,7 +492,7 @@ function zabbixTemplateFormat(value, variable) {
|
||||
function replaceTemplateVars(templateSrv, target, scopedVars) {
|
||||
var replacedTarget = templateSrv.replace(target, scopedVars, zabbixTemplateFormat);
|
||||
if (target !== replacedTarget && !utils.regexPattern.test(replacedTarget)) {
|
||||
replacedTarget = '/' + replacedTarget + '/';
|
||||
replacedTarget = '/^' + replacedTarget + '$/';
|
||||
}
|
||||
return replacedTarget;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ angular
|
||||
$input.attr('data-provide', 'typeahead');
|
||||
|
||||
var options = funcDef.params[paramIndex].options;
|
||||
if (funcDef.params[paramIndex].type === 'int') {
|
||||
if (funcDef.params[paramIndex].type === 'int' ||
|
||||
funcDef.params[paramIndex].type === 'float') {
|
||||
options = _.map(options, function(val) { return val.toString(); });
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,15 @@ addFuncDef({
|
||||
defaultParams: ['1m', 'avg'],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'scale',
|
||||
category: 'Transform',
|
||||
params: [
|
||||
{ name: 'factor', type: 'float', options: [100, 0.01, 10, -1]}
|
||||
],
|
||||
defaultParams: [100],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sumSeries',
|
||||
category: 'Aggregate',
|
||||
@@ -126,8 +135,16 @@ class FuncInstance {
|
||||
|
||||
// Bind function arguments
|
||||
var bindedFunc = func;
|
||||
var param;
|
||||
for (var i = 0; i < this.params.length; i++) {
|
||||
bindedFunc = _.partial(bindedFunc, this.params[i]);
|
||||
param = this.params[i];
|
||||
|
||||
// Convert numeric params
|
||||
if (this.def.params[i].type === 'int' ||
|
||||
this.def.params[i].type === 'float') {
|
||||
param = Number(param);
|
||||
}
|
||||
bindedFunc = _.partial(bindedFunc, param);
|
||||
}
|
||||
return bindedFunc;
|
||||
} else {
|
||||
@@ -140,7 +157,10 @@ class FuncInstance {
|
||||
var parameters = _.map(this.params, function(value, index) {
|
||||
|
||||
var paramType = this.def.params[index].type;
|
||||
if (paramType === 'int' || paramType === 'value_or_series' || paramType === 'boolean') {
|
||||
if (paramType === 'int' ||
|
||||
paramType === 'float' ||
|
||||
paramType === 'value_or_series' ||
|
||||
paramType === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
else if (paramType === 'int_or_interval' && $.isNumeric(value)) {
|
||||
|
||||
@@ -126,6 +126,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Query options -->
|
||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||
<div class="gf-form offset-width-7">
|
||||
<gf-form-switch class="gf-form" ng-hide="ctrl.target.mode == 2"
|
||||
label="Show disabled items"
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metric processing functions -->
|
||||
<div class="gf-form-inline" ng-hide="ctrl.target.mode">
|
||||
<div class="gf-form">
|
||||
@@ -156,15 +167,4 @@
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
|
||||
<!-- Query options -->
|
||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||
<div class="gf-form offset-width-7">
|
||||
<gf-form-switch class="gf-form" ng-hide="ctrl.target.mode == 2"
|
||||
label="Show disabled items"
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</query-editor-row>
|
||||
|
||||
@@ -40,6 +40,11 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
// Update metric suggestion when template variable was changed
|
||||
$rootScope.$on('template-variable-value-updated', () => this.onVariableChange());
|
||||
|
||||
// Update metrics when item selected from dropdown
|
||||
$scope.$on('typeahead-updated', () => {
|
||||
this.onTargetBlur();
|
||||
});
|
||||
|
||||
this.init = function() {
|
||||
var target = this.target;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user