LP13
LP13

Reputation: 34109

AWS cloudwatch is truncating logs

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.

Upvotes: 23

Views: 18516

Answers (2)

rahulbaisla
rahulbaisla

Reputation: 121

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/

Upvotes: 6

A.Khan
A.Khan

Reputation: 3992

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.

Upvotes: 27

Related Questions