Quellcode durchsuchen

Templating: Full support for InfluxDB, filter by part of series names, extract series substrings, nested queries, multipe where clauses! Closes #613

Torkel Ödegaard vor 11 Jahren
Ursprung
Commit
d749549135

+ 1 - 0
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

+ 2 - 2
src/app/partials/templating_editor.html

@@ -122,11 +122,11 @@
 							</div>
 							<div class="editor-option" ng-show="current.includeAll">
 								<label class="small">All format</label>
-								<select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex all values', 'comma list', 'custom']"></select>
+								<select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
 							</div>
 							<div class="editor-option" ng-show="current.includeAll">
 								<label class="small">All value</label>
-								<input type="text" class="input-xlarge" ng-disabled="true" ng-model='current.options[0].value'></input>
+								<input type="text" class="input-xlarge" ng-model='current.options[0].value'></input>
 							</div>
 						</div>
 					</div>

+ 4 - 1
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(',');

+ 11 - 0
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)');
+      });
+    });
+
   });
 
 });