Removed metrics limit from settings.
This commit is contained in:
@@ -14,11 +14,13 @@ function (angular, _, dateMath) {
|
|||||||
function ZabbixAPIDatasource(instanceSettings, $q, backendSrv, templateSrv, alertSrv,
|
function ZabbixAPIDatasource(instanceSettings, $q, backendSrv, templateSrv, alertSrv,
|
||||||
ZabbixAPI, zabbixHelperSrv) {
|
ZabbixAPI, zabbixHelperSrv) {
|
||||||
|
|
||||||
|
// General data source settings
|
||||||
this.name = instanceSettings.name;
|
this.name = instanceSettings.name;
|
||||||
this.url = instanceSettings.url;
|
this.url = instanceSettings.url;
|
||||||
this.basicAuth = instanceSettings.basicAuth;
|
this.basicAuth = instanceSettings.basicAuth;
|
||||||
this.withCredentials = instanceSettings.withCredentials;
|
this.withCredentials = instanceSettings.withCredentials;
|
||||||
|
|
||||||
|
// Zabbix API credentials
|
||||||
this.username = instanceSettings.jsonData.username;
|
this.username = instanceSettings.jsonData.username;
|
||||||
this.password = instanceSettings.jsonData.password;
|
this.password = instanceSettings.jsonData.password;
|
||||||
|
|
||||||
@@ -26,9 +28,6 @@ function (angular, _, dateMath) {
|
|||||||
this.trends = instanceSettings.jsonData.trends;
|
this.trends = instanceSettings.jsonData.trends;
|
||||||
this.trendsFrom = instanceSettings.jsonData.trendsFrom || '7d';
|
this.trendsFrom = instanceSettings.jsonData.trendsFrom || '7d';
|
||||||
|
|
||||||
// Limit metrics per panel for templated request
|
|
||||||
this.limitmetrics = instanceSettings.jsonData.limitMetrics || 100;
|
|
||||||
|
|
||||||
// Initialize Zabbix API
|
// Initialize Zabbix API
|
||||||
this.zabbixAPI = new ZabbixAPI(this.url, this.username, this.password, this.basicAuth, this.withCredentials);
|
this.zabbixAPI = new ZabbixAPI(this.url, this.username, this.password, this.basicAuth, this.withCredentials);
|
||||||
|
|
||||||
@@ -152,45 +151,35 @@ function (angular, _, dateMath) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).then(function (items) {
|
}).then(function (items) {
|
||||||
|
items = _.flatten(items);
|
||||||
|
|
||||||
// Don't perform query for high number of items
|
// Use alias only for single metric, otherwise use item names
|
||||||
// to prevent Grafana slowdown
|
var alias = target.item.name === 'All' || itemnames.length > 1 ?
|
||||||
if (items.length > self.limitmetrics) {
|
undefined : templateSrv.replace(target.alias, options.scopedVars);
|
||||||
var message = "Try to increase limitmetrics parameter in datasource config.<br>"
|
|
||||||
+ "Current limitmetrics value is " + self.limitmetrics;
|
var history;
|
||||||
alertSrv.set("Metrics limit exceeded", message, "warning", 10000);
|
if ((from < useTrendsFrom) && self.trends) {
|
||||||
return [];
|
var points = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
||||||
|
history = self.zabbixAPI.getTrends(items, from, to)
|
||||||
|
.then(_.bind(zabbixHelperSrv.handleTrendResponse, zabbixHelperSrv, items, alias, target.scale, points));
|
||||||
} else {
|
} else {
|
||||||
items = _.flatten(items);
|
history = self.zabbixAPI.getHistory(items, from, to)
|
||||||
|
.then(_.bind(zabbixHelperSrv.handleHistoryResponse, zabbixHelperSrv, items, alias, target.scale));
|
||||||
// Use alias only for single metric, otherwise use item names
|
|
||||||
var alias = target.item.name === 'All' || itemnames.length > 1 ?
|
|
||||||
undefined : templateSrv.replace(target.alias, options.scopedVars);
|
|
||||||
|
|
||||||
var history;
|
|
||||||
if ((from < useTrendsFrom) && self.trends) {
|
|
||||||
var points = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
|
||||||
history = self.zabbixAPI.getTrends(items, from, to)
|
|
||||||
.then(_.bind(zabbixHelperSrv.handleTrendResponse, zabbixHelperSrv, items, alias, target.scale, points));
|
|
||||||
} else {
|
|
||||||
history = self.zabbixAPI.getHistory(items, from, to)
|
|
||||||
.then(_.bind(zabbixHelperSrv.handleHistoryResponse, zabbixHelperSrv, items, alias, target.scale));
|
|
||||||
}
|
|
||||||
|
|
||||||
return history.then(function (timeseries) {
|
|
||||||
var timeseries_data = _.flatten(timeseries);
|
|
||||||
return _.map(timeseries_data, function (timeseries) {
|
|
||||||
|
|
||||||
// Series downsampling
|
|
||||||
if (timeseries.datapoints.length > options.maxDataPoints) {
|
|
||||||
var ms_interval = Math.floor((to - from) / options.maxDataPoints) * 1000;
|
|
||||||
var downsampleFunc = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
|
||||||
timeseries.datapoints = zabbixHelperSrv.downsampleSeries(timeseries.datapoints, to, ms_interval, downsampleFunc);
|
|
||||||
}
|
|
||||||
return timeseries;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return history.then(function (timeseries) {
|
||||||
|
var timeseries_data = _.flatten(timeseries);
|
||||||
|
return _.map(timeseries_data, function (timeseries) {
|
||||||
|
|
||||||
|
// Series downsampling
|
||||||
|
if (timeseries.datapoints.length > options.maxDataPoints) {
|
||||||
|
var ms_interval = Math.floor((to - from) / options.maxDataPoints) * 1000;
|
||||||
|
var downsampleFunc = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
||||||
|
timeseries.datapoints = zabbixHelperSrv.downsampleSeries(timeseries.datapoints, to, ms_interval, downsampleFunc);
|
||||||
|
}
|
||||||
|
return timeseries;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tight-form">
|
<div class="tight-form last">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item" style="width: 80px">
|
<li class="tight-form-item" style="width: 80px">
|
||||||
Trends
|
Trends
|
||||||
@@ -48,16 +48,3 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tight-form last">
|
|
||||||
<ul class="tight-form-list">
|
|
||||||
<li class="tight-form-item" style="width: 80px">
|
|
||||||
Metrics limit
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<input type="text" class="tight-form-input input-small"
|
|
||||||
ng-model='current.jsonData.limitMetrics'
|
|
||||||
placeholder="100">
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user