[release-11.6.2] Graphite: Ensure template variables are interpolated correctly (#105388)

Graphite: Ensure template variables are interpolated correctly (#105354)

(cherry picked from commit e60ece3389)
pull/105549/head
Andreas Christou 2 months ago committed by GitHub
parent 16b472250b
commit e2d00fcfd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      public/app/plugins/datasource/graphite/datasource.test.ts
  2. 2
      public/app/plugins/datasource/graphite/datasource.ts

@ -446,6 +446,22 @@ describe('graphiteDatasource', () => {
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', () => {
const originalTargetMap = {
A: "summarize(prod.25m.count, '25m', 'sum')",

@ -1026,7 +1026,7 @@ export class GraphiteDatasource
}
targetValue = targets[target.refId];
targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer);
targetValue = this.templateSrv.replace(targetValue.replace(regex, nestedSeriesRegexReplacer));
targets[target.refId] = targetValue;
if (!target.hide) {

Loading…
Cancel
Save