Skip to content

Commit

Permalink
Resolved #36 - Ability to use variables in filters (regex).
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Jul 6, 2015
1 parent 69f0d6d commit dcf840f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions zabbix/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ function (angular, _, kbn) {
// Filter hosts by regex
if (target.host.visible_name == 'All') {
if (target.hostFilter && _.every(items, _.identity.hosts)) {
var host_pattern = new RegExp(target.hostFilter);

// Use templated variables in filter
var pattern = templateSrv.replace(target.hostFilter);
var host_pattern = new RegExp(pattern);
items = _.filter(items, function (item) {
return _.some(item.hosts, function (host) {
return host_pattern.test(host.name);
Expand All @@ -102,7 +105,10 @@ function (angular, _, kbn) {

// Filter items by regex
if (target.itemFilter) {
var item_pattern = new RegExp(target.itemFilter);

// Use templated variables in filter
var pattern = templateSrv.replace(target.itemFilter);
var item_pattern = new RegExp(pattern);
return _.filter(items, function (item) {
return item_pattern.test(zabbix.expandItemName(item));
});
Expand Down

0 comments on commit dcf840f

Please sign in to comment.