Review API Gateway detailed CloudWatch metrics

Enable detailed metrics for APIs that need method-level analysis.

Description

REST APIs publish basic metrics for the API and stage. Detailed metrics let you isolate errors and latency by resource and method.

Potential impact

Aggregate values can hide a problem affecting one method.

Remediation

In MethodSettings, set MetricsEnabled to true for the methods you need to monitor individually. Detailed metrics incur additional charges. Check for data after requests to those methods, then configure any error-rate or latency alarms and execution logging separately.

Examples

The /* resource path and * method cover every resource and method in the Prod stage. Define MyRestApi and ApiDeployment separately.

Before

yaml
Resources:
  ProdStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      StageName: Prod
      RestApiId: !Ref MyRestApi
      DeploymentId: !Ref ApiDeployment
      MethodSettings:
        - ResourcePath: /*
          HttpMethod: "*"
          MetricsEnabled: false

After

yaml
Resources:
  ProdStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      StageName: Prod
      RestApiId: !Ref MyRestApi
      DeploymentId: !Ref ApiDeployment
      MethodSettings:
        - ResourcePath: /*
          HttpMethod: "*"
          MetricsEnabled: true

References