From d74954913509bd5482f9785cdd21ba2a05974b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 5 Sep 2014 15:46:29 +0200 Subject: [PATCH] Templating: Full support for InfluxDB, filter by part of series names, extract series substrings, nested queries, multipe where clauses! Closes #613 --- CHANGELOG.md | 1 + src/app/partials/templating_editor.html | 4 ++-- src/app/services/templateValuesSrv.js | 5 ++++- src/test/specs/templateValuesSrv-specs.js | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e2c96b56ea..1fb7ec258ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [Issue #234](https://github.com/grafana/grafana/issues/234). Templating: Interval variable type for time intervals summarize/group by parameter, included "auto" option, and auto step counts option. - [Issue #262](https://github.com/grafana/grafana/issues/262). Templating: Ability to use template variables for function parameters via custom variable type, can be used as parameter for movingAverage or scaleToSeconds for example - [Issue #312](https://github.com/grafana/grafana/issues/312). Templating: Can now use template variables in panel titles +- [Issue #613](https://github.com/grafana/grafana/issues/613). Templating: Full support for InfluxDB, filter by part of series names, extract series substrings, nested queries, multipe where clauses! **InfluxDB Breaking changes** - To better support templating, fill(0) and group by time low limit some changes has been made to the editor and query model schema diff --git a/src/app/partials/templating_editor.html b/src/app/partials/templating_editor.html index b0431b8d1e3..b030f4358f2 100644 --- a/src/app/partials/templating_editor.html +++ b/src/app/partials/templating_editor.html @@ -122,11 +122,11 @@
- +
- +
diff --git a/src/app/services/templateValuesSrv.js b/src/app/services/templateValuesSrv.js index 52d3f51ccb3..511d5bfb495 100644 --- a/src/app/services/templateValuesSrv.js +++ b/src/app/services/templateValuesSrv.js @@ -117,7 +117,7 @@ function (angular, _, kbn) { options = {}; // use object hash to remove duplicates if (variable.regex) { - regex = kbn.stringToJsRegex(variable.regex); + regex = kbn.stringToJsRegex(templateSrv.replace(variable.regex)); } for (i = 0; i < metricNames.length; i++) { @@ -148,6 +148,9 @@ function (angular, _, kbn) { case 'regex wildcard': allValue = '.*'; break; + case 'regex values': + allValue = '(' + _.pluck(variable.options, 'text').join('|') + ')'; + break; default: allValue = '{'; allValue += _.pluck(variable.options, 'text').join(','); diff --git a/src/test/specs/templateValuesSrv-specs.js b/src/test/specs/templateValuesSrv-specs.js index f1faa8d595a..eb1b0225618 100644 --- a/src/test/specs/templateValuesSrv-specs.js +++ b/src/test/specs/templateValuesSrv-specs.js @@ -249,6 +249,17 @@ define([ }); }); + describeUpdateVariable('with include all regex all values', function(scenario) { + scenario.setup(function() { + scenario.variable = { type: 'query', query: 'apps.*', name: 'test', includeAll: true, allFormat: 'regex values' }; + scenario.queryResult = [{text: 'backend1'}, {text: 'backend2'}, { text: 'backend3'}]; + }); + + it('should add empty glob', function() { + expect(scenario.variable.options[0].value).to.be('(backend1|backend2|backend3)'); + }); + }); + }); });