API Gateway Logs: What to Log and What to Query
Last verified on Nov 8, 2026.
API Gateway is the front door for many AWS backends. Its logs are often the quickest way to tell whether a problem is the caller, the gateway or the service behind it. They only exist if you turn them on, and the format is yours to define.
Two kinds of log
AWS describes two types of API logging in CloudWatch:
- Access logging records who accessed your API and how. You create the log group, choose the format and pick which
$contextvariables to include. - Execution logging records the actions API Gateway took to process each request, including errors and execution traces. The Sazabi docs call out REST APIs for this one.
They can be enabled independently. Execution logging needs a CloudWatch Logs role with the AmazonAPIGatewayPushToCloudWatchLogs policy, set once per Region.
Fields worth logging
The AWS variable reference defines these, and they are the ones that answer most questions:
$context.statusis the method response status.$context.integration.statusis the status code the integration returned.$context.responseLatencyis the response latency in milliseconds.$context.identity.sourceIpis the address of the immediate TCP connection.$context.identity.userAgentis the caller's User-Agent header.$context.authorizer.principalIdand$context.authorizer.erroridentify the caller and any authorizer error.$context.wafResponseCodeisWAF_ALLOWorWAF_BLOCKwhen a web ACL is attached.$context.resourcePathnames the route for REST APIs. HTTP and WebSocket APIs use$context.routeKey.
The Sazabi docs recommend a JSON format that includes all of these, which keeps each field searchable.
What to look for
- 5xx by route. Group
statusbyresourcePathand look for one route that dominates. - A gap between
statusandintegrationStatus. If the integration returned 200 and the gateway returned something else, the problem is between them. - 401 and 403 by
iporprincipalId. One caller failing authorization repeatedly is a misconfigured client or a probe. - 429 by caller. Throttled clients show up here.
- Slow routes. Sort by
responseLatencywithin each route, not across the whole API. wafResponseCodeequal toWAF_BLOCK. Pair it with your AWS WAF logs for the rule behind the block.
Example: a failed authorization
This is an example access log line in the JSON format from the Sazabi docs, abbreviated. The values are made up.
{
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"requestTime": "1731070000000",
"ip": "198.51.100.23",
"httpMethod": "GET",
"resourcePath": "/orders/{id}",
"status": "403",
"responseLatency": "14",
"authorizerError": "User is not authorized to access this resource",
"wafResponseCode": "WAF_ALLOW",
"integrationStatus": "-"
}The status is 403 and the integration status is unset because the authorizer refused the call before it reached your service. The latency is short for the same reason. Group that pattern by ip and you can tell a single misbehaving client from a bad deploy that broke authorization for everyone.
How Sazabi reads API Gateway logs
API Gateway writes both log types to CloudWatch Logs, and Sazabi reads them through the same path as the CloudWatch source. The Sazabi docs say to use log group names that start with API-Gateway-Access-Logs_ for access logs. Execution logs go to groups starting with API-Gateway-Execution-Logs_.
There are two ways in:
- If your account is already connected through the native CloudWatch source, turn on API Gateway logging and pick its log groups. No collector is needed.
- Otherwise run an OpenTelemetry Collector Contrib deployment with the
awscloudwatchreceiver. The collector needslogs:DescribeLogGroupsandlogs:FilterLogEvents, the credential stays with your collector and it exports to your Sazabi intake URL. See OpenTelemetry for the collector side.
To confirm records are arriving, the Sazabi docs suggest asking how many API Gateway access log lines arrived in the last 15 minutes, by status. Then search for status 401 or 403 for failed authorizations and 429 for throttled clients.
Related AWS sources
Gateway logs describe requests. VPC Flow Logs describes the network under the services behind it. See the AWS integration page for the full set, and the pricing page for plans.
Set it up
The AWS API Gateway setup guide on docs.sazabi.com walks through connecting it.
What Sazabi detects from these logs today
These detections are on for every production project, with no monitors or alert rules to write. Sazabi opens an issue when one fires.
- Novel event: A kind of error that has never appeared before.
Frequently Asked Questions
What is the difference between access logs and execution logs?
Access logs record who accessed your API and how, in a format you choose. Execution logs record the actions API Gateway took to process requests, including errors and execution traces. You can enable them independently.
How do I find failed authorizations?
Search the access log for status 401 or 403. The authorizerError field, when you include it in the format, gives the authorizer message.
Do I need a collector to get API Gateway logs into Sazabi?
Not if you already connected your AWS account with the native CloudWatch source. Turn on API Gateway logging and pick its log groups in that source.
Does this work for Kong or Apigee?
Those gateways do not write to CloudWatch Logs. The Sazabi docs show how to send their logs through an OpenTelemetry Collector.
Sources
- The recommended access log format, log group name prefixes, the collector configuration and the native CloudWatch alternative (accessed Nov 8, 2026)
- Execution logging versus access logging and the CloudWatch Logs role for the account (accessed Nov 8, 2026)
- Meaning of $context.status, responseLatency, identity.sourceIp, authorizer.error, integration.status and wafResponseCode (accessed Nov 8, 2026)
- HTTP API access logs use $context.routeKey (accessed Nov 8, 2026)