mysql-connector: use consolidateBy in SQL queries as agg func
This commit is contained in:
2
dist/datasource-zabbix/datasource.js
vendored
2
dist/datasource-zabbix/datasource.js
vendored
@@ -371,7 +371,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
} else {
|
||||
// Use history
|
||||
if (_this2.enableDirectDBConnection) {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo, options.intervalMs).then(function (history) {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo, options).then(function (history) {
|
||||
return _this2.zabbix.dbConnector.handleHistory(history, items);
|
||||
});
|
||||
} else {
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
18
dist/datasource-zabbix/zabbixDBConnector.js
vendored
18
dist/datasource-zabbix/zabbixDBConnector.js
vendored
@@ -3,7 +3,7 @@
|
||||
System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var angular, _, _createClass, DEFAULT_QUERY_LIMIT, HISTORY_TO_TABLE_MAP;
|
||||
var angular, _, _createClass, DEFAULT_QUERY_LIMIT, HISTORY_TO_TABLE_MAP, consolidateByFunc;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
@@ -43,11 +43,16 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
}
|
||||
}, {
|
||||
key: 'getHistory',
|
||||
value: function getHistory(items, timeFrom, timeTill, intervalMs) {
|
||||
value: function getHistory(items, timeFrom, timeTill, options) {
|
||||
var _this = this;
|
||||
|
||||
var intervalMs = options.intervalMs,
|
||||
consolidateBy = options.consolidateBy;
|
||||
|
||||
var intervalSec = Math.ceil(intervalMs / 1000);
|
||||
var aggFunction = 'AVG';
|
||||
|
||||
consolidateBy = consolidateBy || 'avg';
|
||||
var aggFunction = consolidateByFunc[consolidateBy];
|
||||
|
||||
// Group items by value type and perform request for each value type
|
||||
var grouped_items = _.groupBy(items, 'value_type');
|
||||
@@ -160,6 +165,13 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
'3': 'history_uint',
|
||||
'4': 'history_text'
|
||||
};
|
||||
consolidateByFunc = {
|
||||
'avg': 'AVG',
|
||||
'min': 'MIN',
|
||||
'max': 'MAX',
|
||||
'sum': 'SUM',
|
||||
'count': 'COUNT'
|
||||
};
|
||||
angular.module('grafana.services').factory('ZabbixDBConnector', ZabbixDBConnectorFactory);
|
||||
}
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user