API Gateway detailed method metrics are disabled

Enable detailed CloudWatch metrics for API methods that need them.

Description

API Gateway’s metrics_enabled controls detailed metrics by resource and method. Basic API-level and stage-level metrics remain available when it is disabled.

Potential impact

Without detailed metrics, isolating latency or error increases for a particular method and configuring method-specific alarms can be harder.

Remediation

Set metrics_enabled = true where method-level monitoring is needed. Select the necessary scope because detailed metrics incur additional charges.

Examples

The examples configure a method on a single-segment resource path. They enable detailed metrics while retaining the execution logging setting.

Before

hcl
resource "aws_api_gateway_method_settings" "example" {
  rest_api_id = aws_api_gateway_rest_api.test.id
  stage_name  = aws_api_gateway_stage.test.stage_name
  method_path = "${aws_api_gateway_resource.test.path_part}/${aws_api_gateway_method.test.http_method}"

  settings {
    metrics_enabled = false
    logging_level   = "INFO"
  }
}

After

hcl
resource "aws_api_gateway_method_settings" "example" {
  rest_api_id = aws_api_gateway_rest_api.test.id
  stage_name  = aws_api_gateway_stage.test.stage_name
  method_path = "${aws_api_gateway_resource.test.path_part}/${aws_api_gateway_method.test.http_method}"

  settings {
    metrics_enabled = true
    logging_level   = "INFO"
  }
}

References