# 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](https://epok.cloud/docs/install/aws).

On this page: What you get Turn on logs Metrics Useful searches Troubleshooting

## 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/ApiGateway` namespace, 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

1. Give API Gateway a role that can write to CloudWatch Logs (the `AmazonAPIGatewayPushToCloudWatchLogs` managed policy), and set it as the API's CloudWatch log role ARN in Settings.
2. On the stage, under Logs/Tracing, enable CloudWatch Logs. For access logging, tick **Enable Access Logging** and set a log format and destination ARN.
3. Add the resulting group (for example `API-Gateway-Execution-Logs_<api-id>/<stage>`) to `EPOK_LOG_GROUPS` and run the setup on [AWS: logs and metrics](https://epok.cloud/docs/install/aws).

## 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 message
```

## Troubleshooting

1. **No group appears.** The stage has CloudWatch Logs off, or the CloudWatch log role ARN is missing or lacks the policy above.
2. **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.
3. **Metrics missing.** `AWS/ApiGateway` is not in the default list. Confirm you ran the metrics setup with `EPOK_METRIC_NAMESPACES=all`, then run `bash aws-metrics.sh --verify-only`.

Next

- [AWS: logs and metrics](https://epok.cloud/docs/install/aws): the one CloudFormation stack this page feeds into.
- [Search syntax](https://epok.cloud/docs/search-syntax): field filters, booleans and pipes.
