Commit d1740f09 by Erik Sundell

stackdriver: make sure unit is not returned to the panel if mapping from…

stackdriver: make sure unit is not returned to the panel if mapping from stackdriver unit to grafana unit can't be made
parent 4687ce2f
......@@ -89,7 +89,7 @@ export default class StackdriverDatasource {
}
resolvePanelUnitFromTargets(targets: any[]) {
let unit = 'none';
let unit;
if (targets.length > 0 && targets.every(t => t.unit === targets[0].unit)) {
if (stackdriverUnitMappings.hasOwnProperty(targets[0].unit)) {
unit = stackdriverUnitMappings[targets[0].unit];
......@@ -109,13 +109,17 @@ export default class StackdriverDatasource {
const unit = this.resolvePanelUnitFromTargets(options.targets);
queryRes.series.forEach(series => {
result.push({
let timeSerie = {
target: series.name,
datapoints: series.points,
refId: queryRes.refId,
meta: queryRes.meta,
unit,
});
};
if (unit) {
timeSerie = { ...timeSerie, unit };
}
result.push(timeSerie);
});
});
}
......
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