diff --git a/public/app/plugins/datasource/stackdriver/datasource.ts b/public/app/plugins/datasource/stackdriver/datasource.ts index 53c2a6937e3..c2fbeaa4488 100644 --- a/public/app/plugins/datasource/stackdriver/datasource.ts +++ b/public/app/plugins/datasource/stackdriver/datasource.ts @@ -12,15 +12,23 @@ export default class StackdriverDatasource { } async getTimeSeries(options) { - const queries = options.targets.filter(target => !target.hide).map(t => ({ - refId: t.refId, - datasourceId: this.id, - metricType: t.metricType, - primaryAggregation: t.aggregation.crossSeriesReducer, - groupBys: t.aggregation.groupBys, - view: t.view || 'FULL', - filters: t.filters, - })); + const queries = options.targets.filter(target => !target.hide).map(t => { + if (!t.hasOwnProperty('aggregation')) { + t.aggregation = { + crossSeriesReducer: 'REDUCE_MEAN', + groupBys: [], + }; + } + return { + refId: t.refId, + datasourceId: this.id, + metricType: t.metricType, + primaryAggregation: t.aggregation.crossSeriesReducer, + groupBys: t.aggregation.groupBys, + view: t.view || 'FULL', + filters: t.filters, + }; + }); const { data } = await this.backendSrv.datasourceRequest({ url: '/api/tsdb/query',