stackdriver: better error handling and show query metadata

If the Stackdriver returns an error, show that error in the query
editor. Also, allow the user to see the raw querystring that was sent
to google (for troubleshooting).
This commit is contained in:
Daniel Lee
2018-09-11 22:41:24 +02:00
parent 2683699ab4
commit 0b5783563e
7 changed files with 218 additions and 117 deletions

View File

@@ -20,26 +20,27 @@ export default class StackdriverDatasource {
const result = [];
try {
const { data } = await this.backendSrv.datasourceRequest({
url: '/api/tsdb/query',
method: 'POST',
data: {
from: options.range.from.valueOf().toString(),
to: options.range.to.valueOf().toString(),
queries,
},
});
const { data } = await this.backendSrv.datasourceRequest({
url: '/api/tsdb/query',
method: 'POST',
data: {
from: options.range.from.valueOf().toString(),
to: options.range.to.valueOf().toString(),
queries,
},
});
if (data.results) {
Object['values'](data.results).forEach(queryRes => {
queryRes.series.forEach(series => {
result.push({ target: series.name, datapoints: series.points });
if (data.results) {
Object['values'](data.results).forEach(queryRes => {
queryRes.series.forEach(series => {
result.push({
target: series.name,
datapoints: series.points,
refId: queryRes.refId,
meta: queryRes.meta,
});
});
}
} catch (error) {
console.log(error);
});
}
return { data: result };