Repository: cdklabs/cdk-monitoring-constructs (language: python)

Issue:
monitorGlueJob creates metric with scale 0-100, but value is scale 0-1
The leftYAxis is specified as a percentage from 0 to 100, but the source glue cpuUsageMetric and heapMemoryUsageMetrics are 0 to 1 values.
https://github.com/cdklabs/cdk-monitoring-constructs/blob/b66685e82733c966eba1555de42c174e1de78a59/lib/monitoring/aws-glue/GlueJobMonitoring.ts#L220
Here is where the metric is built it comes from "glue.ALL.system.cpuSystemLoad" which ranges from 0 to 1. (Similar for heap usage metric as well)
[https://github.com/cdklabs/cdk-monitoring-constructs/blob/b66685e82733c966eba1555d[…]42c174e1de78a59/lib/monitoring/aws-glue/GlueJobMetricFactory.ts](https://github.com/cdklabs/cdk-monitoring-constructs/blob/b66685e82733c966eba1555de42c174e1de78a59/lib/monitoring/aws-glue/GlueJobMetricFactory.ts#L57)
AWS Glue Metrics, state scale is 0-1
https://docs.aws.amazon.com/glue/latest/dg/monitoring-awsglue-with-cloudwatch-metrics.html
I think we either need to use a math metric to multiply the glue metric values by 100 or change the range to 0 to 1 and label it something other than "%".


Discussion / hints:
Thanks for your submission, this is definitely a bug we will fix.
Indeed, the unit is wrong, fixing it now.

https://docs.aws.amazon.com/glue/latest/dg/monitoring-awsglue-with-cloudwatch-metrics.html

Fix patch:
diff --git a/lib/monitoring/aws-glue/GlueJobMetricFactory.ts b/lib/monitoring/aws-glue/GlueJobMetricFactory.ts
index d739ee0a..6824b614 100644
--- a/lib/monitoring/aws-glue/GlueJobMetricFactory.ts
+++ b/lib/monitoring/aws-glue/GlueJobMetricFactory.ts
@@ -55,25 +55,29 @@ export class GlueJobMetricFactory {
   }
 
   metricAverageExecutorCpuUsagePercentage() {
-    return this.metricFactory.createMetric(
+    const label = "CPU Usage (executor average)";
+    const metric = this.metricFactory.createMetric(
       "glue.ALL.system.cpuSystemLoad",
       MetricStatistic.AVERAGE,
-      "CPU Usage (executor average)",
+      label,
       this.dimensionsMap,
       undefined,
       GlueNamespace
     );
+    return this.metricFactory.multiplyMetric(metric, 100, label, "cpu");
   }
 
   metricAverageExecutorMemoryUsagePercentage() {
-    return this.metricFactory.createMetric(
+    const label = "JVM Heap usage (executor average)";
+    const metric = this.metricFactory.createMetric(
       "glue.ALL.jvm.heap.usage",
       MetricStatistic.AVERAGE,
-      "JVM Heap usage (executor average)",
+      label,
       this.dimensionsMap,
       undefined,
       GlueNamespace
     );
+    return this.metricFactory.multiplyMetric(metric, 100, label, "heap");
   }
 
   metricActiveExecutorsAverage() {


Test patch:
diff --git a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
index 013af500..7fb3fa1c 100644
--- a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
+++ b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
@@ -3468,7 +3468,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
@@ -3498,7 +3498,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
             ],
           ],
         },
diff --git a/test/monitoring/aws-glue/__snapshots__/GlueJobMonitoring.test.ts.snap b/test/monitoring/aws-glue/__snapshots__/GlueJobMonitoring.test.ts.snap
index f05bd763..6bc9fad7 100644
--- a/test/monitoring/aws-glue/__snapshots__/GlueJobMonitoring.test.ts.snap
+++ b/test/monitoring/aws-glue/__snapshots__/GlueJobMonitoring.test.ts.snap
@@ -85,7 +85,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
@@ -282,7 +282,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
             ],
           ],
         },
@@ -354,7 +354,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
@@ -383,7 +383,7 @@ Object {
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"Heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"CPU\\",\\"expression\\":\\"cpu * 100\\"}],[\\"Glue\\",\\"glue.ALL.system.cpuSystemLoad\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"CPU Usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"cpu\\"}],[{\\"label\\":\\"Heap\\",\\"expression\\":\\"heap * 100\\"}],[\\"Glue\\",\\"glue.ALL.jvm.heap.usage\\",\\"JobName\\",\\"DummyGlueJob\\",\\"JobRunId\\",\\"ALL\\",\\"Type\\",\\"gauge\\",{\\"label\\":\\"JVM Heap usage (executor average)\\",\\"visible\\":false,\\"id\\":\\"heap\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}}]}",
             ],
           ],
         },