From 530a833844234cbac95d6b899fb5cdcd8145878b Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 19 Aug 2015 20:25:59 +0300 Subject: [PATCH] iss #71 - Able to use regex for extracting a part of the text value. --- zabbix/datasource.js | 17 ++++++++++++++- zabbix/partials/query.editor.html | 36 +++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index 5fa61b4..1cc6212 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -218,7 +218,22 @@ function (angular, _, kbn) { return { target: target.item.name, datapoints: _.map(history, function (p) { - return [p.value, p.clock * 1000]; + var value = p.value; + if (target.textFilter) { + var text_extract_pattern = new RegExp(templateSrv.replace(target.textFilter, options.scopedVars)); + //var text_extract_pattern = new RegExp(target.textFilter); + var result = text_extract_pattern.exec(value); + if (result) { + if (target.useCaptureGroups) { + value = result[1]; + } else { + value = result[0]; + } + } else { + value = null; + } + } + return [value, p.clock * 1000]; }) }; }); diff --git a/zabbix/partials/query.editor.html b/zabbix/partials/query.editor.html index 26e2ea5..533d1f8 100644 --- a/zabbix/partials/query.editor.html +++ b/zabbix/partials/query.editor.html @@ -21,14 +21,14 @@ Numeric metrics -
  • - IT services -
  • Text metrics
  • +
  • + IT services +
  • Duplicate
  • Move up
  • @@ -81,7 +81,7 @@