From d1bac6cde079c76959261097d846f6a46935aef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 1 Mar 2016 16:11:05 +0100 Subject: [PATCH] feat(templating): prometheus now works with new template variable formating/escaping, #2918 --- docker/blocks/prometheus/prometheus.yml | 2 +- public/app/features/templating/templateSrv.js | 2 +- public/app/plugins/datasource/prometheus/datasource.ts | 2 +- public/app/plugins/datasource/prometheus/plugin.json | 3 +-- public/test/specs/templateSrv-specs.js | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docker/blocks/prometheus/prometheus.yml b/docker/blocks/prometheus/prometheus.yml index b0fc2a919cd..5c853622af3 100644 --- a/docker/blocks/prometheus/prometheus.yml +++ b/docker/blocks/prometheus/prometheus.yml @@ -23,4 +23,4 @@ scrape_configs: # scheme defaults to 'http'. target_groups: - - targets: ['localhost:9090', '172.17.42.1:9091'] + - targets: ['localhost:9090', '172.17.0.1:9091'] diff --git a/public/app/features/templating/templateSrv.js b/public/app/features/templating/templateSrv.js index 1f1153bda44..011b3150e2f 100644 --- a/public/app/features/templating/templateSrv.js +++ b/public/app/features/templating/templateSrv.js @@ -50,7 +50,7 @@ function (angular, _) { } var escapedValues = _.map(value, regexEscape); - return '(' + escapedValues.join('|') + ')'; + return escapedValues.join('|'); } case "lucene": { if (typeof value === 'string') { diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index 6c4cbc216ae..55ce628d53d 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -52,7 +52,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS } var query: any = {}; - query.expr = templateSrv.replace(target.expr, options.scopedVars); + query.expr = templateSrv.replace(target.expr, options.scopedVars, 'regex'); var interval = target.interval || options.interval; var intervalFactor = target.intervalFactor || 1; diff --git a/public/app/plugins/datasource/prometheus/plugin.json b/public/app/plugins/datasource/prometheus/plugin.json index 1b9d569f6df..66dd9145e6a 100644 --- a/public/app/plugins/datasource/prometheus/plugin.json +++ b/public/app/plugins/datasource/prometheus/plugin.json @@ -4,6 +4,5 @@ "id": "prometheus", "metrics": true, - "annotations": true, - "defaultMatchFormat": "pipe" + "annotations": true } diff --git a/public/test/specs/templateSrv-specs.js b/public/test/specs/templateSrv-specs.js index 669dc14c8e4..d48cd04e7bf 100644 --- a/public/test/specs/templateSrv-specs.js +++ b/public/test/specs/templateSrv-specs.js @@ -127,7 +127,7 @@ define([ it('multi value and regex format should render regex string', function() { var result = _templateSrv.formatValue(['test.','test2'], 'regex'); - expect(result).to.be('(test\\.|test2)'); + expect(result).to.be('test\\.|test2'); }); it('multi value and pipe should render pipe string', function() {