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

Issue:
Alarms created for ApiGateway using monitorScope uses the default stage "prod" instead of the stage deployed
### Version

v4.0.9

### Steps and/or minimal code example to reproduce

Since the stacks created at my organizations are deployed to multiple environments (development, staging, production etc) and depending on the environment it exists in the stage in the ApiGateway is different. When I use `monitorScope` for `apiGateway` it is creating alarms for the stage `prod` (which appears to be the default when `apiStage` is not provided) instead of what I have in the ApiGateway that is deployed. I'm not seeing a way to specify `apiStage` when using `monitorScope`. Shouldn't that automatically deduce that when it uses Aspects or is there a way to specify it when using `monitorScope` that I missed?

Below is an example code that I use:

```
 monitoringFacade.monitorScope(this, {
        apiGateway: {
          props: {
              add5XXFaultRateAlarm: {
                Warning: {
                  maxErrorRate: 0.1,
                  datapointsToAlarm: 2,
                  treatMissingDataOverride: TreatMissingData.NOT_BREACHING,
                },
              },
              add4XXErrorRateAlarm: {
                Warning: {
                  maxErrorRate: 0.2,
                  datapointsToAlarm: 2,
                  treatMissingDataOverride: TreatMissingData.NOT_BREACHING,
                },
              },
          },
          enabled:  true,
        }
     }
   );
```

### Expected behavior

The alarms that are created for ApiGateway when using `monitorScope` uses the stage that exists in ApiGateway based on the template. Alternatively, provide a way to override the default if there are challenges to made this deduction using aspects.

### Actual behavior

The alarms are created for stage `prod` 

### Other details

_No response_


Discussion / hints:
Here it does not add the `apiStage` using the `deploymentStage` information from the apiGateWay https://github.com/cdklabs/cdk-monitoring-constructs/blob/fbd348c4eaa2e406c86727359d88d1c70ae72d80/lib/facade/MonitoringAspect.ts#L108

And since it is not added the default `prod` from https://github.com/cdklabs/cdk-monitoring-constructs/blob/fbd348c4eaa2e406c86727359d88d1c70ae72d80/lib/monitoring/aws-apigateway/ApiGatewayMonitoring.ts#L114 gets used.

The code I'm pointing to above is 5.x of the cdk-monitoring constructs, but 4.x is probably similar. This results in the alarms created for the wrong deployment stage in my case when I use `monitorScope`.

Fix patch:
diff --git a/lib/facade/MonitoringAspect.ts b/lib/facade/MonitoringAspect.ts
index a3ae0247..e411f838 100644
--- a/lib/facade/MonitoringAspect.ts
+++ b/lib/facade/MonitoringAspect.ts
@@ -106,6 +106,7 @@ export class MonitoringAspect implements IAspect {
     if (isEnabled && node instanceof apigw.RestApi) {
       this.monitoringFacade.monitorApiGateway({
         api: node,
+        apiStage: node.deploymentStage.stageName,
         ...props,
       });
     }


Test patch:
diff --git a/test/facade/MonitoringAspect.test.ts b/test/facade/MonitoringAspect.test.ts
index 03cb94b6..d80ee55a 100644
--- a/test/facade/MonitoringAspect.test.ts
+++ b/test/facade/MonitoringAspect.test.ts
@@ -89,6 +89,18 @@ describe("MonitoringAspect", () => {
     const api = new apigw.RestApi(stack, "DummyRestApi");
     api.root.addMethod("ANY");
 
+    const deployment = new apigw.Deployment(stack, "DummyRestApiDeployment", {
+      api,
+    });
+    new apigw.Stage(stack, "DummyRestApiDevStage", {
+      deployment,
+      stageName: "DevStage",
+    });
+    api.deploymentStage = new apigw.Stage(stack, "DummyRestApiProdStage", {
+      deployment,
+      stageName: "ProdStage",
+    });
+
     // WHEN
     facade.monitorScope(stack, defaultAspectProps);
 
diff --git a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
index cf3677d1..146509b6 100644
--- a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
+++ b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap
@@ -147,23 +147,59 @@ Object {
           "Fn::Join": Array [
             "",
             Array [
-              "{\\"start\\":\\"-PT8H\\",\\"periodOverride\\":\\"inherit\\",\\"widgets\\":[{\\"type\\":\\"text\\",\\"width\\":24,\\"height\\":1,\\"x\\":0,\\"y\\":0,\\"properties\\":{\\"markdown\\":\\"### API Gateway Endpoint **DummyRestApi prod**\\"}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":0,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"TPS\\",\\"region\\":\\"",
+              "{\\"start\\":\\"-PT8H\\",\\"periodOverride\\":\\"inherit\\",\\"widgets\\":[{\\"type\\":\\"text\\",\\"width\\":24,\\"height\\":1,\\"x\\":0,\\"y\\":0,\\"properties\\":{\\"markdown\\":\\"### API Gateway Endpoint **DummyRestApi ",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "**\\"}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":0,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"TPS\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[{\\"label\\":\\"Count/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/ApiGateway\\",\\"Count\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"Count\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"Count/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/ApiGateway\\",\\"Count\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"Count\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P50 (avg: \${AVG})\\",\\"stat\\":\\"p50\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P90 (avg: \${AVG})\\",\\"stat\\":\\"p90\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P99 (avg: \${AVG})\\",\\"stat\\":\\"p99\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P50 (avg: \${AVG})\\",\\"stat\\":\\"p50\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P90 (avg: \${AVG})\\",\\"stat\\":\\"p90\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P99 (avg: \${AVG})\\",\\"stat\\":\\"p99\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"4XX Error\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"5XX Fault\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"4XX Error\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"5XX Fault\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"4XX Error (avg)\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"5XX Fault (avg)\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}",
+              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"4XX Error (avg)\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"5XX Fault (avg)\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}",
             ],
           ],
         },
@@ -177,19 +213,47 @@ Object {
           "Fn::Join": Array [
             "",
             Array [
-              "{\\"start\\":\\"-P14D\\",\\"periodOverride\\":\\"inherit\\",\\"widgets\\":[{\\"type\\":\\"text\\",\\"width\\":24,\\"height\\":1,\\"x\\":0,\\"y\\":0,\\"properties\\":{\\"markdown\\":\\"### API Gateway Endpoint **DummyRestApi prod**\\"}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":0,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"TPS\\",\\"region\\":\\"",
+              "{\\"start\\":\\"-P14D\\",\\"periodOverride\\":\\"inherit\\",\\"widgets\\":[{\\"type\\":\\"text\\",\\"width\\":24,\\"height\\":1,\\"x\\":0,\\"y\\":0,\\"properties\\":{\\"markdown\\":\\"### API Gateway Endpoint **DummyRestApi ",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "**\\"}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":0,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"TPS\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[{\\"label\\":\\"Count/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/ApiGateway\\",\\"Count\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"Count\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[{\\"label\\":\\"Count/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/ApiGateway\\",\\"Count\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"Count\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P50 (avg: \${AVG})\\",\\"stat\\":\\"p50\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P90 (avg: \${AVG})\\",\\"stat\\":\\"p90\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"P99 (avg: \${AVG})\\",\\"stat\\":\\"p99\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"",
+              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P50 (avg: \${AVG})\\",\\"stat\\":\\"p50\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P90 (avg: \${AVG})\\",\\"stat\\":\\"p90\\"}],[\\"AWS/ApiGateway\\",\\"Latency\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"P99 (avg: \${AVG})\\",\\"stat\\":\\"p99\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"",
               Object {
                 "Ref": "AWS::Region",
               },
-              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"4XX Error (avg)\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"prod\\",{\\"label\\":\\"5XX Fault (avg)\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}",
+              "\\",\\"metrics\\":[[\\"AWS/ApiGateway\\",\\"4XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"4XX Error (avg)\\"}],[\\"AWS/ApiGateway\\",\\"5XXError\\",\\"ApiName\\",\\"DummyRestApi\\",\\"Stage\\",\\"",
+              Object {
+                "Ref": "DummyRestApiProdStageB70B7437",
+              },
+              "\\",{\\"label\\":\\"5XX Fault (avg)\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}",
             ],
           ],
         },
@@ -271,6 +335,17 @@ Object {
       "Type": "AWS::IAM::Role",
       "UpdateReplacePolicy": "Retain",
     },
+    "DummyRestApiDeployment1CA45D1Eb2b2ef98b0af2d8440e2a441c4976e4c": Object {
+      "DependsOn": Array [
+        "DummyRestApiANYCDDCFD86",
+      ],
+      "Properties": Object {
+        "RestApiId": Object {
+          "Ref": "DummyRestApi328A173A",
+        },
+      },
+      "Type": "AWS::ApiGateway::Deployment",
+    },
     "DummyRestApiDeploymentE536A000827e68cce8aade0ba98340f42cbf5e9e": Object {
       "DependsOn": Array [
         "DummyRestApiANYCDDCFD86",
@@ -298,6 +373,36 @@ Object {
       },
       "Type": "AWS::ApiGateway::Stage",
     },
+    "DummyRestApiDevStage9C608189": Object {
+      "DependsOn": Array [
+        "DummyRestApiAccount722BC8C0",
+      ],
+      "Properties": Object {
+        "DeploymentId": Object {
+          "Ref": "DummyRestApiDeployment1CA45D1Eb2b2ef98b0af2d8440e2a441c4976e4c",
+        },
+        "RestApiId": Object {
+          "Ref": "DummyRestApi328A173A",
+        },
+        "StageName": "DevStage",
+      },
+      "Type": "AWS::ApiGateway::Stage",
+    },
+    "DummyRestApiProdStageB70B7437": Object {
+      "DependsOn": Array [
+        "DummyRestApiAccount722BC8C0",
+      ],
+      "Properties": Object {
+        "DeploymentId": Object {
+          "Ref": "DummyRestApiDeployment1CA45D1Eb2b2ef98b0af2d8440e2a441c4976e4c",
+        },
+        "RestApiId": Object {
+          "Ref": "DummyRestApi328A173A",
+        },
+        "StageName": "ProdStage",
+      },
+      "Type": "AWS::ApiGateway::Stage",
+    },
   },
   "Rules": Object {
     "CheckBootstrapVersion": Object {