Amazon lambda 不显示 python 日志 [英] Amazon lambda does not show python logs

查看:25
本文介绍了Amazon lambda 不显示 python 日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 API(Python) 部署在 Amazon Lambda 上.问题是当我请求我的 API 时,我收到内部服务器错误.我可以跟踪 Lambda 日志,但我看不到代码崩溃的实际错误或堆栈跟踪.当我跟踪日志时,我只会得到以下输出.

My API(Python) is deployed on Amazon Lambda. The problem is when I request my API I get the internal server error. I can tail the Lambda logs but I don't see the actual error or stack trace where the code crashed. When I tail the logs I just get the following output.

START RequestId: 62341bgd-6231-11e8-8c5b-25793532a32u Version: $LATEST
END RequestId: 62341b0d-6231-1128-8r5b-2b793032a3ed
REPORT RequestId: 6234te0b-6rte-aaa8-au5a-21t93132r3rt  Duration: 0.46 ms

如何查看用于调试的 Python api 的实际堆栈跟踪?

How can I see the actual stack trace of my python api for debugging?

推荐答案

初步调查:

默认情况下,lambda 函数以我的 API 的名称在 CloudWatch 中创建日志组.例如,/aws/lambda/my_api_name 显示了类似这样的输出.

By default lambda function created log group in CloudWatch by the name of my API. For example, /aws/lambda/my_api_name which shows the output something like this.

START RequestId: 62341bgd-6231-11e8-8c5b-25793532a32u Version: $LATEST
END RequestId: 62341b0d-6231-1128-8r5b-2b793032a3ed
REPORT RequestId: 6234te0b-6rte-aaa8-au5a-21t93132r3rt  Duration: 0.46 ms

问题解决:

我为我的云监视创建了一个服务角色(AWS 已经提供的所有云监视权限的默认策略),然后将此角色放入我的 API 中.我遵循了这个方法.但是,另一个步骤可以是将新创建的执行日志与默认日志组合在一起,这样我们就有一个日志组要拖尾.

I created a service role for my cloud watch(Default policy for all the rights for the cloudWatch already provided by AWS) and then put this role into my API. I followed this approach. However, another step could be combine the newly created execution logs with the default one so we have one log group to tail.

这篇关于Amazon lambda 不显示 python 日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆