简体   繁体   English

为什么我看不到 Lambda 函数的 CloudWatch 日志?

[英]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.

相关问题 为什么我在 lambda 函数中看不到日志? - Why can't I see logs in my lambda function? 为什么我在 CloudWatch 和 lambda function 的控制台中看不到我的日志? - Why I don't see my log in the console at CloudWatch and lambda function? 从 AWS Lambda function 运行:可以看到 CloudWatch 日志,除了 axios 的延续 - Running from AWS Lambda function: can see CloudWatch logs, except in axios's continuation CloudWatch登录Python Lambda函数 - CloudWatch Logs in Python Lambda function 如何在 CloudWatch 中查看 AWS CloudFormation 日志? - How can I see AWS CloudFormation logs in CloudWatch? 禁用 CloudWatch 以监控 Lambda 函数的日志 - Disable CloudWatch to monitor logs for Lambda function lambda功能日志未正确记录在cloudwatch中 - lambda function logs are not properly logged in cloudwatch 为什么在“ AWS Lambda高级功能详细信息”对话框中看不到角色列表? - Why can't I see the role list in AWS Lambda Advanced Function Details dialog? 为什么我在创建 AWS Lambda function 后看不到编辑内联代码和处理程序信息的选项 - why I can't see the option to edit code inline and handler Info on after creating the AWS Lambda function AWS Lambda函数日志未在CloudWatch中显示 - AWS lambda function logs are not getting displayed in cloudwatch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM