diff --git a/public/app/features/templating/specs/template_srv_specs.ts b/public/app/features/templating/specs/template_srv_specs.ts index 94b1e211293..ca336e97ba3 100644 --- a/public/app/features/templating/specs/template_srv_specs.ts +++ b/public/app/features/templating/specs/template_srv_specs.ts @@ -145,6 +145,11 @@ describe('templateSrv', function() { expect(result).to.be('test|test2'); }); + it('multi value and distributed should render distributed string', function() { + var result = _templateSrv.formatValue(['test','test2'], 'distributed', { name: 'build' }); + expect(result).to.be('test,build=test2'); + }); + it('slash should be properly escaped in regex format', function() { var result = _templateSrv.formatValue('Gi3/14', 'regex'); expect(result).to.be('Gi3\\/14'); diff --git a/public/app/features/templating/templateSrv.js b/public/app/features/templating/templateSrv.js index dadb8f23a89..e4627ac6165 100644 --- a/public/app/features/templating/templateSrv.js +++ b/public/app/features/templating/templateSrv.js @@ -95,6 +95,9 @@ function (angular, _, kbn) { } return value.join('|'); } + case "distributed": { + return this.distributeVariable(value, variable.name); + } default: { if (typeof value === 'string') { return value; @@ -210,6 +213,17 @@ function (angular, _, kbn) { }); }; + this.distributeVariable = function(value, variable) { + value = _.map(value, function(val, index) { + if (index !== 0) { + return variable + "=" + val; + } else { + return val; + } + }); + return value.join(','); + }; + }); }); diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 4ef7c9761fe..76ee763cafc 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -244,7 +244,7 @@ function (angular, _, dateMath) { var interpolated; try { - interpolated = templateSrv.replace(query); + interpolated = templateSrv.replace(query, {}, 'distributed'); } catch (err) { return $q.reject(err);