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