Commit 97727d16 by Erik Sundell Committed by Daniel Lee

Stackdriver: Add backed query using

parent 73a42df0
/** @ngInject */ /** @ngInject */
export default class StackdriverDatasource { export default class StackdriverDatasource {
id: number;
url: string; url: string;
baseUrl: string; baseUrl: string;
...@@ -7,10 +8,30 @@ export default class StackdriverDatasource { ...@@ -7,10 +8,30 @@ export default class StackdriverDatasource {
this.baseUrl = `/stackdriver/`; this.baseUrl = `/stackdriver/`;
this.url = instanceSettings.url; this.url = instanceSettings.url;
this.doRequest = this.doRequest; this.doRequest = this.doRequest;
this.id = instanceSettings.id;
} }
query() { async query(options) {
return Promise.resolve(); const queries = options.targets.filter(target => !target.hide).map(t => ({
queryType: 'raw',
refId: t.refId,
datasourceId: this.id,
metric: t.metricType,
}));
try {
const response = await this.backendSrv.datasourceRequest({
url: '/api/tsdb/query',
method: 'POST',
data: {
from: options.range.from.valueOf().toString(),
to: options.range.to.valueOf().toString(),
queries,
},
});
return response;
} catch (error) {
console.log(error);
}
} }
testDatasource() { testDatasource() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment