From add23d9716c580791e6d4913371f5934dac039e1 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 13 Sep 2018 18:22:48 +0200 Subject: [PATCH] stackdriver: load time series meta data for group by dropdown --- pkg/tsdb/stackdriver/stackdriver.go | 1 + .../datasource/stackdriver/datasource.ts | 14 +++-- .../stackdriver/partials/query.editor.html | 10 +-- .../datasource/stackdriver/query_ctrl.ts | 62 ++++++++++++++++--- 4 files changed, 69 insertions(+), 18 deletions(-) diff --git a/pkg/tsdb/stackdriver/stackdriver.go b/pkg/tsdb/stackdriver/stackdriver.go index f2aa2399ffe..4796278fe76 100644 --- a/pkg/tsdb/stackdriver/stackdriver.go +++ b/pkg/tsdb/stackdriver/stackdriver.go @@ -103,6 +103,7 @@ func (e *StackdriverExecutor) buildQueries(tsdbQuery *tsdb.TsdbQuery) ([]*Stackd params.Add("interval.startTime", startTime.UTC().Format(time.RFC3339)) params.Add("interval.endTime", endTime.UTC().Format(time.RFC3339)) params.Add("filter", "metric.type=\""+metricType+"\"") + params.Add("view", query.Model.Get("view").MustString()) setAggParams(¶ms, query) if setting.Env == setting.DEV { diff --git a/public/app/plugins/datasource/stackdriver/datasource.ts b/public/app/plugins/datasource/stackdriver/datasource.ts index 2ad4faecad5..a65154739d4 100644 --- a/public/app/plugins/datasource/stackdriver/datasource.ts +++ b/public/app/plugins/datasource/stackdriver/datasource.ts @@ -11,17 +11,16 @@ export default class StackdriverDatasource { this.id = instanceSettings.id; } - async query(options) { + 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, + primaryAggregation: 'REDUCE_MEAN', //t.aggregation.crossSeriesReducer, + // groupBys: t.aggregation.groupBys, + view: t.view || 'FULL', })); - const result = []; - const { data } = await this.backendSrv.datasourceRequest({ url: '/api/tsdb/query', method: 'POST', @@ -31,7 +30,12 @@ export default class StackdriverDatasource { queries, }, }); + return data; + } + async query(options) { + const result = []; + const data = await this.getTimeSeries(options); if (data.results) { Object['values'](data.results).forEach(queryRes => { if (!queryRes.series) { diff --git a/public/app/plugins/datasource/stackdriver/partials/query.editor.html b/public/app/plugins/datasource/stackdriver/partials/query.editor.html index dbcc10e9ed3..9395e8981a3 100755 --- a/public/app/plugins/datasource/stackdriver/partials/query.editor.html +++ b/public/app/plugins/datasource/stackdriver/partials/query.editor.html @@ -2,8 +2,8 @@
Metric Type - +
@@ -30,8 +30,8 @@
Project - +