Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trace full-request / response bodies in AWS ApiGateway (not truncated)

I am using AWS Api Gateway and I'd like to trace full request and response. Some of my integrations are lambdas and some other http endpoints.

I enabled stage > Logs > "Log full requests/responses data" and I can see logs on CloudWatch.

This seemed to be perfect until I discovered bodies were being TRUNCATED... There is a limitation of 1024 bytes in ApiGateway sending logs to cloudwatch.

Is there any solution to this?

I am considering using a lambda as a proxy (with http-proxy) as my last option...

like image 996
Jorgeblom Avatar asked May 16 '18 07:05

Jorgeblom


People also ask

How do I enable access Logs for API gateway AWS?

Choose the Enable Access Logging check box. For Access Log Destination ARN, enter the ARN of an Amazon Kinesis Data Firehose (this is only supported in REST APIs) or a CloudWatch log group. Enter a Log Format. For guidance, choose CLF, JSON, XML, or CSV to see an example in that format.


2 Answers

As you stated, there is no current known solution to this problem and AWS is aware of the problem.

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.

You can see additional known issues at the AWS documentation page for API Gateway here.

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html

like image 70
Cory Burke Avatar answered Oct 06 '22 20:10

Cory Burke


According to the AWS documentation, full logging should not be turned on in AWS API Gateway, in production, because of PII (source).

This is purely for development troubleshooting purposes. So the log limitation 1024 bytes continue to exists, because of this.

like image 29
Amit Avatar answered Oct 06 '22 22:10

Amit