[英]Why can't I see CloudWatch Logs for Lambda function?
I wanted to be able to monitor logs in Cloudwatch when my Lambda being executed, currently there is a section on the top of Lambda console:我希望能够在执行 Lambda 时监控 Cloudwatch 中的日志,目前 Lambda 控制台顶部有一个部分:
It's showing me any error I got when the Lambda is being executed, but if I click on logs
, it will direct me to CloudWatch and showing me log group does not exist
, does anyone know why and how I'll be able to see the logs in Cloudwatch?它向我显示了执行 Lambda 时遇到的任何错误,但是如果我单击
logs
,它会将我定向到 CloudWatch 并显示log group does not exist
,有谁知道为什么以及如何查看登录 Cloudwatch? (I thought it'll be automatical...) (我以为它会自动...)
此问题的最常见原因是您尚未将 IAM 角色分配给有权在 CloudWatch 中创建日志的 Lambda 函数。
Your AWS Lambda function needs the following permissions to access CloudWatch Logs:您的 AWS Lambda 函数需要以下权限才能访问 CloudWatch Logs:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
This will give it permission to create a log group and store events in the log group.这将授予它创建日志组并将事件存储在日志组中的权限。
The easiest way to assign this permission is by adding the AWSLambdaBasicExecutionRole
managed policy to the IAM Role being used by your Lambda function.分配此权限的最简单方法是将
AWSLambdaBasicExecutionRole
托管策略添加到您的 Lambda 函数正在使用的 IAM 角色。
Your log group should be created automatically.您的日志组应该是自动创建的。
If you click on details arrow you will see the reason it failed, probably it crashed.如果您单击详细信息箭头,您将看到它失败的原因,可能是它崩溃了。
I suppose you got a lambda runtime error, before your handler is run.我想您在运行处理程序之前遇到了 lambda 运行时错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.