Apply downsampling only to numeric data, fixes #325

This commit is contained in:
Alexander Zobnin
2017-06-18 18:37:27 +03:00
parent 86191998ab
commit 2d64a73030
5 changed files with 29 additions and 31 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Item name expanding when key contains commas in quoted params, like my_key["a=1,b=2",c,d]
- Incorrect points order when trends are used [#202](https://github.com/alexanderzobnin/grafana-zabbix/issues/202)
- Triggers panel styles for light theme
- Bug with text metrics when singlestat or table shows NaN, [#325](https://github.com/alexanderzobnin/grafana-zabbix/issues/325)
### Changed
- Template query format. New format is `{group}{host}{app}{item}`. It allows to use names with dot. Updated

View File

@@ -286,7 +286,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}
if (!target.mode || target.mode === c.MODE_METRICS) {
return _this.queryNumericData(target, timeRange, useTrends);
return _this.queryNumericData(target, timeRange, useTrends, options);
} else if (target.mode === c.MODE_TEXT) {
return _this.queryTextData(target, timeRange);
}
@@ -306,25 +306,23 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
});
// Data for panel (all targets)
return Promise.all(_.flatten(promises)).then(_.flatten).then(function (timeseries_data) {
return downsampleSeries(timeseries_data, options);
}).then(function (data) {
return Promise.all(_.flatten(promises)).then(_.flatten).then(function (data) {
return { data: data };
});
}
}, {
key: 'queryNumericData',
value: function queryNumericData(target, timeRange, useTrends) {
value: function queryNumericData(target, timeRange, useTrends, options) {
var _this2 = this;
var _timeRange = _slicedToArray(timeRange, 2),
timeFrom = _timeRange[0],
timeTo = _timeRange[1];
var options = {
var getItemOptions = {
itemtype: 'num'
};
return this.zabbix.getItemsFromTarget(target, options).then(function (items) {
return this.zabbix.getItemsFromTarget(target, getItemOptions).then(function (items) {
var getHistoryPromise = void 0;
if (useTrends) {
@@ -348,9 +346,11 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
});
}
return getHistoryPromise.then(function (timeseries_data) {
return _this2.applyDataProcessingFunctions(timeseries_data, target);
});
return getHistoryPromise;
}).then(function (timeseries) {
return _this2.applyDataProcessingFunctions(timeseries, target);
}).then(function (timeseries) {
return downsampleSeries(timeseries, options);
}).catch(function (error) {
console.log(error);
return [];

File diff suppressed because one or more lines are too long

View File

@@ -159,7 +159,7 @@ var ZabbixAPIDatasource = function () {
}
if (!target.mode || target.mode === c.MODE_METRICS) {
return _this.queryNumericData(target, timeRange, useTrends);
return _this.queryNumericData(target, timeRange, useTrends, options);
} else if (target.mode === c.MODE_TEXT) {
return _this.queryTextData(target, timeRange);
}
@@ -179,25 +179,23 @@ var ZabbixAPIDatasource = function () {
});
// Data for panel (all targets)
return Promise.all(_lodash2.default.flatten(promises)).then(_lodash2.default.flatten).then(function (timeseries_data) {
return downsampleSeries(timeseries_data, options);
}).then(function (data) {
return Promise.all(_lodash2.default.flatten(promises)).then(_lodash2.default.flatten).then(function (data) {
return { data: data };
});
}
}, {
key: 'queryNumericData',
value: function queryNumericData(target, timeRange, useTrends) {
value: function queryNumericData(target, timeRange, useTrends, options) {
var _this2 = this;
var _timeRange = _slicedToArray(timeRange, 2),
timeFrom = _timeRange[0],
timeTo = _timeRange[1];
var options = {
var getItemOptions = {
itemtype: 'num'
};
return this.zabbix.getItemsFromTarget(target, options).then(function (items) {
return this.zabbix.getItemsFromTarget(target, getItemOptions).then(function (items) {
var getHistoryPromise = void 0;
if (useTrends) {
@@ -221,9 +219,11 @@ var ZabbixAPIDatasource = function () {
});
}
return getHistoryPromise.then(function (timeseries_data) {
return _this2.applyDataProcessingFunctions(timeseries_data, target);
});
return getHistoryPromise;
}).then(function (timeseries) {
return _this2.applyDataProcessingFunctions(timeseries, target);
}).then(function (timeseries) {
return downsampleSeries(timeseries, options);
}).catch(function (error) {
console.log(error);
return [];

View File

@@ -104,7 +104,7 @@ class ZabbixAPIDatasource {
}
if (!target.mode || target.mode === c.MODE_METRICS) {
return this.queryNumericData(target, timeRange, useTrends);
return this.queryNumericData(target, timeRange, useTrends, options);
} else if (target.mode === c.MODE_TEXT) {
return this.queryTextData(target, timeRange);
}
@@ -127,20 +127,17 @@ class ZabbixAPIDatasource {
// Data for panel (all targets)
return Promise.all(_.flatten(promises))
.then(_.flatten)
.then(timeseries_data => {
return downsampleSeries(timeseries_data, options);
})
.then(data => {
return { data: data };
});
}
queryNumericData(target, timeRange, useTrends) {
queryNumericData(target, timeRange, useTrends, options) {
let [timeFrom, timeTo] = timeRange;
let options = {
let getItemOptions = {
itemtype: 'num'
};
return this.zabbix.getItemsFromTarget(target, options)
return this.zabbix.getItemsFromTarget(target, getItemOptions)
.then(items => {
let getHistoryPromise;
@@ -166,10 +163,10 @@ class ZabbixAPIDatasource {
});
}
return getHistoryPromise.then(timeseries_data => {
return this.applyDataProcessingFunctions(timeseries_data, target);
});
return getHistoryPromise;
})
.then(timeseries => this.applyDataProcessingFunctions(timeseries, target))
.then(timeseries => downsampleSeries(timeseries, options))
.catch(error => {
console.log(error);
return [];