mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(templating): prometheus now works with new template variable formating/escaping, #2918
This commit is contained in:
@@ -23,4 +23,4 @@ scrape_configs:
|
|||||||
# scheme defaults to 'http'.
|
# scheme defaults to 'http'.
|
||||||
|
|
||||||
target_groups:
|
target_groups:
|
||||||
- targets: ['localhost:9090', '172.17.42.1:9091']
|
- targets: ['localhost:9090', '172.17.0.1:9091']
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var escapedValues = _.map(value, regexEscape);
|
var escapedValues = _.map(value, regexEscape);
|
||||||
return '(' + escapedValues.join('|') + ')';
|
return escapedValues.join('|');
|
||||||
}
|
}
|
||||||
case "lucene": {
|
case "lucene": {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|||||||
}
|
}
|
||||||
|
|
||||||
var query: any = {};
|
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 interval = target.interval || options.interval;
|
||||||
var intervalFactor = target.intervalFactor || 1;
|
var intervalFactor = target.intervalFactor || 1;
|
||||||
|
|||||||
@@ -4,6 +4,5 @@
|
|||||||
"id": "prometheus",
|
"id": "prometheus",
|
||||||
|
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
"annotations": true,
|
"annotations": true
|
||||||
"defaultMatchFormat": "pipe"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ define([
|
|||||||
|
|
||||||
it('multi value and regex format should render regex string', function() {
|
it('multi value and regex format should render regex string', function() {
|
||||||
var result = _templateSrv.formatValue(['test.','test2'], 'regex');
|
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() {
|
it('multi value and pipe should render pipe string', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user