Add metrics limit per panel.

This commit is contained in:
Alexander Zobnin
2015-05-28 21:12:40 +03:00
parent 2c58bc4ba9
commit feb729de52

View File

@@ -19,6 +19,9 @@ function (angular, _, kbn) {
this.username = datasource.meta.username; this.username = datasource.meta.username;
this.password = datasource.meta.password; this.password = datasource.meta.password;
// Limit metrics per panel
this.limitmetrics = datasource.meta.limitmetrics || 20;
// For testing // For testing
this.ds = datasource; this.ds = datasource;
} }
@@ -55,6 +58,7 @@ function (angular, _, kbn) {
var key_pattern = /([\w\.]+(?:\[[^\[]*\])|[\w\.]+)/g; var key_pattern = /([\w\.]+(?:\[[^\[]*\])|[\w\.]+)/g;
var keys = item_key.match(key_pattern); var keys = item_key.match(key_pattern);
if (keys.length < this.limitmetrics) {
// Find items by keys and perform queries // Find items by keys and perform queries
var self = this; var self = this;
return $q.all(_.map(hosts, function (hostname) { return $q.all(_.map(hosts, function (hostname) {
@@ -66,6 +70,9 @@ function (angular, _, kbn) {
return self.performTimeSeriesQuery(items, from, to) return self.performTimeSeriesQuery(items, from, to)
.then(_.partial(self.handleZabbixAPIResponse, items)); .then(_.partial(self.handleZabbixAPIResponse, items));
}); });
} else {
return [];
}
} }
}, this); }, this);
@@ -108,7 +115,7 @@ function (angular, _, kbn) {
}; };
// Request data from Zabbix API // Convert Zabbix API data to Grafana format
ZabbixAPIDatasource.prototype.handleZabbixAPIResponse = function(items, response) { ZabbixAPIDatasource.prototype.handleZabbixAPIResponse = function(items, response) {
/** /**
* Response should be in the format: * Response should be in the format: