Graphite: Ensure template variables are interpolated correctly (#105354)
This commit is contained in:
@@ -446,6 +446,22 @@ describe('graphiteDatasource', () => {
|
|||||||
expect(results[2]).toBe('target=' + encodeURIComponent('asPercent(series1,sumSeries(series1))'));
|
expect(results[2]).toBe('target=' + encodeURIComponent('asPercent(series1,sumSeries(series1))'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should replace target placeholder when nesting query references with template variables', () => {
|
||||||
|
ctx.templateSrv.init([{ type: 'query', name: 'metric', current: { value: ['aMetricName'] } }]);
|
||||||
|
const originalTargetMap = {
|
||||||
|
A: '[[metric]]',
|
||||||
|
B: 'sumSeries(#A)',
|
||||||
|
C: 'asPercent(#A,#B)',
|
||||||
|
};
|
||||||
|
const results = ctx.ds.buildGraphiteParams(
|
||||||
|
{
|
||||||
|
targets: [{ target: '[[metric]]' }, { target: 'sumSeries(#A)' }, { target: 'asPercent(#A,#B)' }],
|
||||||
|
},
|
||||||
|
originalTargetMap
|
||||||
|
);
|
||||||
|
expect(results[2]).toBe('target=' + encodeURIComponent('asPercent(aMetricName,sumSeries(aMetricName))'));
|
||||||
|
});
|
||||||
|
|
||||||
it('should fix wrong minute interval parameters', () => {
|
it('should fix wrong minute interval parameters', () => {
|
||||||
const originalTargetMap = {
|
const originalTargetMap = {
|
||||||
A: "summarize(prod.25m.count, '25m', 'sum')",
|
A: "summarize(prod.25m.count, '25m', 'sum')",
|
||||||
|
|||||||
@@ -1026,7 +1026,7 @@ export class GraphiteDatasource
|
|||||||
}
|
}
|
||||||
|
|
||||||
targetValue = targets[target.refId];
|
targetValue = targets[target.refId];
|
||||||
targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer);
|
targetValue = this.templateSrv.replace(targetValue.replace(regex, nestedSeriesRegexReplacer));
|
||||||
targets[target.refId] = targetValue;
|
targets[target.refId] = targetValue;
|
||||||
|
|
||||||
if (!target.hide) {
|
if (!target.hide) {
|
||||||
|
|||||||
Reference in New Issue
Block a user