19

I have created an API using AWS api gateway. Under stages the "Log full requests/responses data" checked and "Enable CloudWatch Logs" is also checked.

When i look at the logs in cloudwatch i see some of the logs are "TRUNCATED". In-fact all of the logs are truncating request and response body. Is there any way to view the entire request/response.

Since there will be multiple integration points it make sense to see the entire logs.

LP13
  • 30,567
  • 53
  • 217
  • 400

2 Answers2

25

Looks like it's one of the known issues in AWS API Gateway.

API Gateway currently limits log events to 1024 bytes. Log events larger than 1024 bytes, such as request and response bodies, will be truncated by API Gateway before submission to CloudWatch Logs.

A.Khan
  • 3,826
  • 21
  • 25
  • 19
    hmm it does not make sense to truncate log in serverless application because thats the only way we can debug. Right now i don't know exactly what payLoad API gateway is passing to Lambda function – LP13 Jan 08 '19 at 22:40
5

API Gateway limits log events to 1024 bytes and cannot be increased. The log events larger than 1024 bytes, such as request and response bodies, will be truncated by API Gateway before submission to CloudWatch Logs.

A workaround can be using Lambda proxy integration with API Gateway.

With Lambda proxy integration, API Gateway passes the request as is to the integrated Lambda function with only exception that the order of the request parameters is not preserved.

This request data includes the request headers, query string parameters, URL path variables, payload, body and request context. As Lambda does not truncate log entry, all headers and query string parameters are logged in Lambda's CloudWatch log and can be seen.

Downside of this approach is that lambda would add to the cost.

Read about API Gateway CloudWatch logs here : https://cloudnamaste.com/api-gateway-cloudwatch-logs/

rahulbaisla
  • 101
  • 1
  • 3