Fixed templated items parsing (fixed regexps)
This commit is contained in:
@@ -25,12 +25,8 @@ 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
|
// Limit metrics per panel for templated request
|
||||||
this.limitmetrics = datasource.meta.limitmetrics || 20;
|
this.limitmetrics = datasource.meta.limitmetrics || 50;
|
||||||
|
|
||||||
// For testing
|
|
||||||
this.ds = datasource;
|
|
||||||
this.auth = 'testauth'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,12 +77,14 @@ function (angular, _, kbn) {
|
|||||||
var hosts = hostname.match(host_pattern);
|
var hosts = hostname.match(host_pattern);
|
||||||
|
|
||||||
// Remove hostnames from item names and then
|
// Remove hostnames from item names and then
|
||||||
// Extract item names
|
// extract item names
|
||||||
// "hostname: itemname" --> "itemname"
|
// "hostname: itemname" --> "itemname"
|
||||||
var delete_hostname_pattern = /(?:\[[\w\.]+\]\:\s)/g;
|
var delete_hostname_pattern = /(?:\[[\w\.]+\]\:\s)/g;
|
||||||
var itemname_pattern = /([^{},]+)/g;
|
var remove_brackets_pattern = /^{|}$/g;
|
||||||
|
var itemname_split_pattern = /(,(?!\s))/g;
|
||||||
var itemnames = itemname.replace(delete_hostname_pattern, '')
|
var itemnames = itemname.replace(delete_hostname_pattern, '')
|
||||||
.match(itemname_pattern);
|
.replace(remove_brackets_pattern, '')
|
||||||
|
.split(itemname_split_pattern);
|
||||||
//var aliases = itemname.match(itemname_pattern);
|
//var aliases = itemname.match(itemname_pattern);
|
||||||
|
|
||||||
// Don't perform query for high number of items
|
// Don't perform query for high number of items
|
||||||
|
|||||||
@@ -30,13 +30,17 @@ function (angular, _) {
|
|||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Take alias from item name by default
|
|
||||||
|
/**
|
||||||
|
* Take alias from item name by default
|
||||||
|
*/
|
||||||
function setItemAlias() {
|
function setItemAlias() {
|
||||||
if (!$scope.target.alias && $scope.target.item) {
|
if (!$scope.target.alias && $scope.target.item) {
|
||||||
$scope.target.alias = expandItemName($scope.target.item);
|
$scope.target.alias = expandItemName($scope.target.item);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.targetBlur = function() {
|
$scope.targetBlur = function() {
|
||||||
setItemAlias();
|
setItemAlias();
|
||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
@@ -46,7 +50,10 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call when host group selected
|
|
||||||
|
/**
|
||||||
|
* Call when host group selected
|
||||||
|
*/
|
||||||
$scope.selectHostGroup = function() {
|
$scope.selectHostGroup = function() {
|
||||||
$scope.updateHostList()
|
$scope.updateHostList()
|
||||||
$scope.updateAppList();
|
$scope.updateAppList();
|
||||||
@@ -58,7 +65,10 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call when host selected
|
|
||||||
|
/**
|
||||||
|
* Call when host selected
|
||||||
|
*/
|
||||||
$scope.selectHost = function() {
|
$scope.selectHost = function() {
|
||||||
$scope.updateItemList();
|
$scope.updateItemList();
|
||||||
$scope.updateAppList();
|
$scope.updateAppList();
|
||||||
@@ -71,7 +81,9 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Call when application selected
|
/**
|
||||||
|
* Call when application selected
|
||||||
|
*/
|
||||||
$scope.selectApplication = function() {
|
$scope.selectApplication = function() {
|
||||||
$scope.updateItemList();
|
$scope.updateItemList();
|
||||||
|
|
||||||
@@ -83,7 +95,9 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Call when item selected
|
/**
|
||||||
|
* Call when item selected
|
||||||
|
*/
|
||||||
$scope.selectItem = function() {
|
$scope.selectItem = function() {
|
||||||
setItemAlias();
|
setItemAlias();
|
||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
@@ -209,6 +223,11 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add templated variables to list of available metrics
|
||||||
|
*
|
||||||
|
* @param {Array} metricList List of metrics which variables add to
|
||||||
|
*/
|
||||||
function addTemplatedVariables(metricList) {
|
function addTemplatedVariables(metricList) {
|
||||||
_.each(templateSrv.variables, function(variable) {
|
_.each(templateSrv.variables, function(variable) {
|
||||||
metricList.push({
|
metricList.push({
|
||||||
@@ -223,8 +242,8 @@ function (angular, _) {
|
|||||||
* Expand item parameters, for example:
|
* Expand item parameters, for example:
|
||||||
* CPU $2 time ($3) --> CPU system time (avg1)
|
* CPU $2 time ($3) --> CPU system time (avg1)
|
||||||
*
|
*
|
||||||
* @param item: zabbix api item object
|
* @param {Object} item Zabbix item object
|
||||||
* @return: expanded item name (string)
|
* @return {string} expanded item name
|
||||||
*/
|
*/
|
||||||
function expandItemName(item) {
|
function expandItemName(item) {
|
||||||
var name = item.name;
|
var name = item.name;
|
||||||
|
|||||||
Reference in New Issue
Block a user