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,17 +58,21 @@ 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);
// Find items by keys and perform queries if (keys.length < this.limitmetrics) {
var self = this; // Find items by keys and perform queries
return $q.all(_.map(hosts, function (hostname) { var self = this;
return $q.all(_.map(keys, function (key) { return $q.all(_.map(hosts, function (hostname) {
return this.findZabbixItem(hostname, key); return $q.all(_.map(keys, function (key) {
}, this)); return this.findZabbixItem(hostname, key);
}, this)).then(function (items) { }, this));
items = _.flatten(items); }, this)).then(function (items) {
return self.performTimeSeriesQuery(items, from, to) items = _.flatten(items);
.then(_.partial(self.handleZabbixAPIResponse, items)); return self.performTimeSeriesQuery(items, from, to)
}); .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: