AWS API Gateway logs and metrics
Updated Nov 22, 2026 · today
API Gateway can write access and execution logs to CloudWatch Logs, and publishes request and error metrics under the AWS/ApiGateway namespace. Both reach Epok through the shared setup on AWS: logs and metrics.
On this page: What you getTurn on logsMetricsUseful searchesTroubleshooting
What you get
- Logs: access-log lines (the format you choose: CLF, JSON, XML or CSV) and execution logs, from a group like
API-Gateway-Execution-Logs_<api-id>/<stage>. - Metrics: the
AWS/ApiGatewaynamespace, which includes count, 4XXError, 5XXError, latency and integration latency.
Each log event is stored with _msg (the access or execution line, as text), _time, a level detected from words in the line, service (the stage),log_group, log_stream, cloud.provider, cloud.account_id and cloud.region. The access-log line itself is not parsed into fields yet, so the JSON inside a JSON-format line is searchable as text.
Turn on logs
- Give API Gateway a role that can write to CloudWatch Logs (the
AmazonAPIGatewayPushToCloudWatchLogsmanaged policy), and set it as the API's CloudWatch log role ARN in Settings. - On the stage, under Logs/Tracing, enable CloudWatch Logs. For access logging, tick Enable Access Logging and set a log format and destination ARN.
- Add the resulting group (for example
API-Gateway-Execution-Logs_<api-id>/<stage>) toEPOK_LOG_GROUPSand run the setup on AWS: logs and metrics.
Metrics
The namespace is AWS/ApiGateway. It is not in the default metric stream list, so to receive it run the metrics setup with EPOK_METRIC_NAMESPACES=all (streams every namespace; check the cost first).
Useful searches
log_group:"API-Gateway-Execution-Logs_abc123/prod" level:error # execution-log errors, one stage
log_group:"<your-access-log-group>" _msg:"504" # access lines that contain 504, as text
service:prod _time:1h | stats by (_msg) count() # top line shapes for the stage
_msg:err* # prefix match across the messageTroubleshooting
- No group appears. The stage has CloudWatch Logs off, or the CloudWatch log role ARN is missing or lacks the policy above.
- Access-log fields are not filterable.The access line is stored as text in
_msg, so search it with_msg:and text operators; parsed fields come later. - Metrics missing.
AWS/ApiGatewayis not in the default list. Confirm you ran the metrics setup withEPOK_METRIC_NAMESPACES=all, then runbash aws-metrics.sh --verify-only.
Next
- AWS: logs and metrics: the one CloudFormation stack this page feeds into.
- Search syntax: field filters, booleans and pipes.