stackdriver: move response parsing to datasource file

This commit is contained in:
Erik Sundell
2018-11-09 13:55:08 +01:00
parent 7ccce76b80
commit cbb663015e
2 changed files with 7 additions and 5 deletions
@@ -70,7 +70,7 @@ export default class StackdriverDatasource {
}
async getLabels(metricType, refId) {
return await this.getTimeSeries({
const response = await this.getTimeSeries({
targets: [
{
refId: refId,
@@ -84,6 +84,8 @@ export default class StackdriverDatasource {
],
range: this.timeSrv.timeRange(),
});
return response.results[refId];
}
interpolateGroupBys(groupBys: string[], scopedVars): string[] {
@@ -150,10 +150,10 @@ export class StackdriverFilterCtrl {
async getLabels() {
this.loadLabelsPromise = new Promise(async resolve => {
try {
const data = await this.datasource.getLabels(this.target.metricType, this.target.refId);
this.metricLabels = data.results[this.target.refId].meta.metricLabels;
this.resourceLabels = data.results[this.target.refId].meta.resourceLabels;
this.resourceTypes = data.results[this.target.refId].meta.resourceTypes;
const { meta } = await this.datasource.getLabels(this.target.metricType, this.target.refId);
this.metricLabels = meta.metricLabels;
this.resourceLabels = meta.resourceLabels;
this.resourceTypes = meta.resourceTypes;
resolve();
} catch (error) {
if (error.data && error.data.message) {