diff --git a/plugins/datasource-zabbix/datasource.js b/plugins/datasource-zabbix/datasource.js index 2707868..06a3b1a 100644 --- a/plugins/datasource-zabbix/datasource.js +++ b/plugins/datasource-zabbix/datasource.js @@ -225,7 +225,22 @@ function (angular, _, dateMath) { 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/plugins/datasource-zabbix/partials/query.editor.html b/plugins/datasource-zabbix/partials/query.editor.html index 5a85dc5..383d965 100644 --- a/plugins/datasource-zabbix/partials/query.editor.html +++ b/plugins/datasource-zabbix/partials/query.editor.html @@ -76,7 +76,7 @@ + +
+
Text filter
+ +