API Gateway の実行ログの動きメモ
まずAPI Gatewayのログにはアクセスログと実行ログがある。以下記事が分かりやすい。
マネジメントコンソールでいえば以下に該当。

これを有効にするとCloudWatch Logsのロググループが勝手に作成されていた。ただし、このグループへのリンクがAPI Gatewayの画面には見当たらないので分かりづらいなと。これは命名規則が決まっているようだ。
以下がロググループ名であり、名前にステージ名が加えられているとおり、ステージごとに有効にする必要があるらしい。
API-Gateway-Execution-Logs_{APIのID}/{ステージ名}

これがAPIレベルではどう見えるか確認してみた。
ロググループ有効化前に get-stage APIでステージを取得すると以下のとおり
aws apigateway get-stage --rest-api-id xxxxxxx --stage-name Prod { "deploymentId": "xxxxx", "stageName": "Prod", "cacheClusterEnabled": false, "cacheClusterStatus": "NOT_AVAILABLE", "methodSettings": {}, "tracingEnabled": false, "tags": { "aws:cloudformation:logical-id": "ServerlessRestApiProdStage", "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:1111111111111111:stack/sam-log/xxxxxxxxxxxxx", "aws:cloudformation:stack-name": "sam-log" }, "createdDate": "2026-06-28T10:59:51+09:00", "lastUpdatedDate": "2026-06-28T10:59:51+09:00" }
有効化後は以下のとおり。 methodSettings に実行ログに関する情報が追加されているのが分かる。
{ "deploymentId": "gna1vm", "stageName": "Prod", "cacheClusterEnabled": false, "cacheClusterStatus": "NOT_AVAILABLE", "methodSettings": { "*/*": { "metricsEnabled": false, "loggingLevel": "ERROR", "dataTraceEnabled": false, "throttlingBurstLimit": 5000, "throttlingRateLimit": 10000.0, "cachingEnabled": false, "cacheTtlInSeconds": 300, "cacheDataEncrypted": false, "requireAuthorizationForCacheControl": true, "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER" } }, "tracingEnabled": false, "tags": { "aws:cloudformation:logical-id": "ServerlessRestApiProdStage", "aws:cloudformation:stack-id": "arn:aws:cloudformation:ap-northeast-1:1111111111111:stack/sam-log/22222-222222-11f1-aa35-211111", "aws:cloudformation:stack-name": "sam-log" }, "createdDate": "2026-06-28T10:59:51+09:00", "lastUpdatedDate": "2026-06-28T16:32:53+09:00" }