简体   繁体   English

AWS cloudwatch 正在截断日志

[英]AWS cloudwatch is truncating logs

I have created an API using AWS api gateway.我已经使用 AWS api 网关创建了一个 API。 Under stages the "Log full requests/responses data" checked and "Enable CloudWatch Logs" is also checked.在阶段下,“记录完整的请求/响应数据”和“启用 CloudWatch 日志”也被选中。

When i look at the logs in cloudwatch i see some of the logs are "TRUNCATED".当我查看 cloudwatch 中的日志时,我看到一些日志被“截断”。 In-fact all of the logs are truncating request and response body .事实上,所有日志都在截断 request 和 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.由于将有多个集成点,因此查看整个日志是有意义的。

Looks like it's one of the known issues in AWS API Gateway.看起来这是 AWS API Gateway 中的已知问题之一。

API Gateway currently limits log events to 1024 bytes. API Gateway 目前将日志事件限制为 1024 字节。 Log events larger than 1024 bytes, such as request and response bodies, will be truncated by API Gateway before submission to CloudWatch Logs.大于 1024 字节的日志事件(例如请求和响应正文)将在提交到 CloudWatch Logs 之前被 API Gateway 截断。

API Gateway limits log events to 1024 bytes and cannot be increased. API Gateway 将日志事件限制为 1024 字节且不能增加。 The log events larger than 1024 bytes, such as request and response bodies, will be truncated by API Gateway before submission to CloudWatch Logs.大于 1024 字节的日志事件(例如请求和响应正文)将在提交到 CloudWatch Logs 之前被 API Gateway 截断。

A workaround can be using Lambda proxy integration with API Gateway.一种解决方法是使用 Lambda 代理与 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.通过 Lambda 代理集成,API Gateway 将请求按原样传递给集成的 Lambda 函数,唯一的例外是不保留请求参数的顺序。

This request data includes the request headers, query string parameters, URL path variables, payload, body and request context.此请求数据包括请求标头、查询字符串参数、URL 路径变量、有效负载、正文和请求上下文。 As Lambda does not truncate log entry, all headers and query string parameters are logged in Lambda's CloudWatch log and can be seen.由于 Lambda 不会截断日志条目,因此所有标头和查询字符串参数都记录在 Lambda 的 CloudWatch 日志中并且可以看到。

Downside of this approach is that lambda would add to the cost.这种方法的缺点是 lambda 会增加成本。

Read about API Gateway CloudWatch logs here : https://cloudnamaste.com/api-gateway-cloudwatch-logs/在此处阅读 API Gateway CloudWatch 日志: https ://cloudnamaste.com/api-gateway-cloudwatch-logs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM