Review API Gateway detailed CloudWatch metrics

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

Description

Without detailed metrics for REST API methods in API Gateway, errors or latency for a particular path and method can be harder to distinguish. Turning off MetricsEnabled does not disable all basic API-level and stage-level CloudWatch metrics.

Detailed metrics incur additional charges, so select the scope needed for operations. Metric collection, logging and alarm configuration are separate.

Potential impact

  • Errors or delays in individual methods may be obscured by aggregate metrics, slowing response.
  • Collecting unnecessary detailed metrics can increase monitoring costs.

Remediation

Select the methods that need individual observation and set MetricsEnabled to true in MethodSettings. Verify that metrics arrive and configure the required alarms for error rates, latency or other signals separately. Review the analytical value and additional cost.

Examples

These excerpts show the same REST API stage. Prepare 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

This disables detailed metrics for all resources and methods in the stage. Basic API-level and stage-level metrics are provided separately.

After

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

This enables detailed metrics for all resources and methods. Confirm that the full scope is needed and configure alarms separately.

References