Prompt
api gateway logs missing request IDs
Latest observation
If your API Gateway logs are missing request IDs, the fix usually depends on which gateway you’re using and which logs you mean:
- Access logs
- Execution logs
- Backend/app logs
A few common causes and fixes:
1) API Gateway isn’t configured to log the ID you want
Many gateways don’t automatically include a request ID in access logs unless you explicitly add it to the log format.
For AWS API Gateway
In Access Log Settings, include fields like:
$context.requestId$context.extendedRequestId$context.awsEndpointRequestId
Example format:
{
"requestId":"$context.requestId",
"extendedRequestId":"$context.extendedRequestId",
"ip":"$context.identity.sourceIp",
"time":"$context.requestTime",
"method":"$context.httpMethod",
"path":"$context.resourcePath",
"status":"$context.status"
}
2) You’re looking at execution logs, not access logs
Execution logs often show gateway processing steps, but the request ID may appear differently or only at certain log levels.
For AWS, make sure:
- CloudWatch logging is enabled
- Log level is set appropriately
- Access logging is configured
3) Request ID isn’t propagated to the backend
If your backend app expects the gateway’s request ID, it may not be forwarded automatically.
Check headers like:
X-Request-IdX-Correlation-IdX-Amzn-RequestId
You may need to map/inject one in the gateway integration.
4) Sampling / truncation / format issues
If logs are JSON and the field is missing:
- verify the log format string is valid
- ensure the logging destination isn’t dropping fields
- check whether some requests bypass logging (health checks, auth failures, etc.)
5) Different IDs can be confused
AWS often has multiple IDs:
requestIdextendedRequestIdx-amzn-requestid
They are not always the same, and some are only available in certain contexts.
If you want, I can help you troubleshoot this for a specific platform, for example:
- AWS API Gateway
- Azure API Management
- Google Cloud API Gateway
- Kong / NGINX / Apigee
If you share:
- gateway type
- sample log line
- whether this is access or execution logs
I can give you the exact fix.