Browse Source

stackdriver: make sure unit is not returned to the panel if mapping from stackdriver unit to grafana unit can't be made

Erik Sundell 7 years ago
parent
commit
d1740f090a
1 changed files with 7 additions and 3 deletions
  1. 7 3
      public/app/plugins/datasource/stackdriver/datasource.ts

+ 7 - 3
public/app/plugins/datasource/stackdriver/datasource.ts

@@ -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);
         });
       });
     }