- Newest
- Most votes
- Most comments
Based on the available context variables for API Gateway access logs, there is no standard variable specifically for request payload size. The logging variables available include $context.responseLength which captures the response payload length in bytes, but there isn't a corresponding $context.requestLength or similar variable for the incoming request size.
The blank field you're seeing is expected behavior because API Gateway's access log variables don't include a built-in parameter for request payload size. The standard variables you can use focus on request metadata (like request ID, request time, route key), caller information (source IP, user agent), and response characteristics (response length, status code, latency).
For HTTP APIs specifically, the available logging variables include:
- Request identifiers and timing information
- Response metrics like
$context.responseLengthand$context.responseLatency - Route and stage information
- HTTP method and status codes
However, request body size is not among the supported variables.
If capturing request size is critical for your use case, you might need to consider alternative approaches such as:
- Implementing custom logging within your backend integration to capture and log the request size
- Using AWS X-Ray tracing (available for REST APIs) which may provide additional request details
- Processing CloudWatch Logs with custom metrics to derive request size information from other available data
The behavior is consistent across API types - neither REST APIs nor HTTP APIs provide a native context variable for request payload size in access logs.
Sources
Customize HTTP API access logs - Amazon API Gateway
Amazon API Gateway controls - AWS Control Tower
Relevant content
asked 5 years ago
asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
