Repository navigation
Replies: 2 comments 1 reply
|
Hello! Reopening this discussion to make it searchable. |
|
In AWS CDK for API Gateway v1 ( It is configured through 1. Enable Detailed Metrics Across the Entire StageTo enable detailed CloudWatch metrics for all resources and methods in your import * as apigateway from 'aws-cdk-lib/aws-apigateway';
const api = new apigateway.RestApi(this, 'MyRestApi', {
deployOptions: {
stageName: 'prod',
metricsEnabled: true, // <--- Enables detailed CloudWatch metrics for all methods
loggingLevel: apigateway.MethodLoggingLevel.INFO,
dataTraceEnabled: false,
},
});2. Enable Detailed Metrics for Specific Methods OnlyIf you only want detailed metrics on specific high-traffic or critical routes (to optimize CloudWatch custom metrics costs): const api = new apigateway.RestApi(this, 'MyRestApi', {
deployOptions: {
stageName: 'prod',
methodOptions: {
// Wildcard for all methods under a specific resource
'/items/*': {
metricsEnabled: true,
},
// Or an exact path and HTTP verb
'/orders/GET': {
metricsEnabled: true,
},
},
},
});3. How It Maps to CloudFormationUnder the hood, CDK compiles this into the Type: AWS::ApiGateway::Stage
Properties:
StageName: prod
MethodSettings:
- ResourcePath: '/*'
HttpMethod: '*'
MetricsEnabled: trueWhat You Get:Once enabled, API Gateway publishes detailed per-method metrics to Amazon CloudWatch under the namespace
These include |
Uh oh!
There was an error while loading. Please reload this page.
detailedMetricsEnabledis available for the HttpApi in API Gateway v2, but seemingly isnt for the API Gateway RestApi. What gives?All reactions