diff --git a/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html b/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html
index 06ef9e5e3ff..0e30e21ad1f 100755
--- a/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html
+++ b/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html
@@ -20,8 +20,10 @@
-
+
+
diff --git a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
index 512035103f5..2de1c10d918 100644
--- a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+++ b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
@@ -26,7 +26,7 @@ export class StackdriverAggregationCtrl {
target: any;
/** @ngInject */
- constructor(private $scope) {
+ constructor(private $scope, private templateSrv) {
this.$scope.ctrl = this;
this.target = $scope.target;
this.alignmentPeriods = options.alignmentPeriods;
@@ -51,7 +51,7 @@ export class StackdriverAggregationCtrl {
setAggOptions() {
this.aggOptions = getAggregationOptionsByMetric(this.target.valueType, this.target.metricKind);
- if (!this.aggOptions.find(o => o.value === this.target.aggregation.crossSeriesReducer)) {
+ if (!this.aggOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.crossSeriesReducer))) {
this.deselectAggregationOption('REDUCE_NONE');
}
diff --git a/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts b/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
index ac9ea2ac6bc..81011f5dfe0 100644
--- a/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
+++ b/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
@@ -6,10 +6,19 @@ describe('StackdriverAggregationCtrl', () => {
describe('when new query result is returned from the server', () => {
describe('and result is double and gauge and no group by is used', () => {
beforeEach(async () => {
- ctrl = new StackdriverAggregationCtrl({
- $on: () => {},
- target: { valueType: 'DOUBLE', metricKind: 'GAUGE', aggregation: { crossSeriesReducer: '', groupBys: [] } },
- });
+ ctrl = new StackdriverAggregationCtrl(
+ {
+ $on: () => {},
+ target: {
+ valueType: 'DOUBLE',
+ metricKind: 'GAUGE',
+ aggregation: { crossSeriesReducer: '', groupBys: [] },
+ },
+ },
+ {
+ replace: s => s,
+ }
+ );
});
it('should populate all aggregate options except two', () => {
@@ -31,14 +40,19 @@ describe('StackdriverAggregationCtrl', () => {
describe('and result is double and gauge and a group by is used', () => {
beforeEach(async () => {
- ctrl = new StackdriverAggregationCtrl({
- $on: () => {},
- target: {
- valueType: 'DOUBLE',
- metricKind: 'GAUGE',
- aggregation: { crossSeriesReducer: 'REDUCE_NONE', groupBys: ['resource.label.projectid'] },
+ ctrl = new StackdriverAggregationCtrl(
+ {
+ $on: () => {},
+ target: {
+ valueType: 'DOUBLE',
+ metricKind: 'GAUGE',
+ aggregation: { crossSeriesReducer: 'REDUCE_NONE', groupBys: ['resource.label.projectid'] },
+ },
},
- });
+ {
+ replace: s => s,
+ }
+ );
});
it('should populate all aggregate options except three', () => {