Просмотр исходного кода

Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax), Fixes #1372

Torkel Ödegaard 11 лет назад
Родитель
Сommit
d3c37bda71
3 измененных файлов с 9 добавлено и 0 удалено
  1. 1 0
      CHANGELOG.md
  2. 1 0
      src/app/features/graphite/datasource.js
  3. 7 0
      src/test/specs/graphiteDatasource-specs.js

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@
 - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query
 - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query
 - [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold
 - [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold
 - [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down
 - [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down
+- [Issue #1372](https://github.com/grafana/grafana/issues/1372). Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax)
 
 
 **Tech**
 **Tech**
 - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2
 - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2

+ 1 - 0
src/app/features/graphite/datasource.js

@@ -276,6 +276,7 @@ function (angular, _, $, config, kbn, moment) {
 
 
         targetValue = targets[this._seriesRefLetters[i]];
         targetValue = targets[this._seriesRefLetters[i]];
         targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer);
         targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer);
+        targets[this._seriesRefLetters[i]] = targetValue;
 
 
         clean_options.push("target=" + encodeURIComponent(targetValue));
         clean_options.push("target=" + encodeURIComponent(targetValue));
       }
       }

+ 7 - 0
src/test/specs/graphiteDatasource-specs.js

@@ -74,6 +74,13 @@ define([
         expect(results[2]).to.be('target=asPercent(series1%2Cseries2)');
         expect(results[2]).to.be('target=asPercent(series1%2Cseries2)');
       });
       });
 
 
+      it('should replace target placeholder when nesting query references', function() {
+        var results = ctx.ds.buildGraphiteParams({
+          targets: [{target: 'series1'}, {target: 'sumSeries(#A)'}, {target: 'asPercent(#A,#B)'}]
+        });
+        expect(results[2]).to.be('target=' + encodeURIComponent("asPercent(series1,sumSeries(series1))"));
+      });
+
       it('should fix wrong minute interval parameters', function() {
       it('should fix wrong minute interval parameters', function() {
         var results = ctx.ds.buildGraphiteParams({
         var results = ctx.ds.buildGraphiteParams({
           targets: [{target: "summarize(prod.25m.count, '25m', 'sum')" }]
           targets: [{target: "summarize(prod.25m.count, '25m', 'sum')" }]