无法使AWS Lambda函数登录(文本输出)到CloudWatch [英] Can't get AWS Lambda function to log (text output) to CloudWatch

查看:104
本文介绍了无法使AWS Lambda函数登录(文本输出)到CloudWatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个Lambda函数,该函数将在文件上传到S3存储桶时对其进行处理。上传文件时,我需要一种方法来查看 console.log 的输出,但是我不知道如何将Lambda函数链接到CloudWatch。

I'm trying to set up a Lambda function that will process a file when it's uploaded to an S3 bucket. I need a way to see the output of console.log when I upload a file, but I can't figure out how to link my Lambda function to CloudWatch.

我通过查看上下文对象发现了我的日志组为 / aws / lambda / wavToMp3 ,日志流为 2016/05/23 / [$ LATEST] hex_code_redacted 。因此,我在CloudWatch中创建了该组和流,但是没有任何日志记录到它。

I figured about by looking at the context object that my log group is /aws/lambda/wavToMp3 and the log stream is 2016/05/23/[$LATEST]hex_code_redacted. So I created that group and stream in CloudWatch, yet nothing is being logged to it.

推荐答案

用于lambda函数创建日志将日志流传输并发布到cloudwatch之后,lambda执行角色需要具有以下权限。

For the lambda function to create log stream and publish logs to cloudwatch, the lambda execution role needs to have the following permissions.

{
    "Statement": [
        {
            "Action": [
                "logs:CreateLogGroup",
                 "logs:CreateLogStream",
                 "logs:PutLogEvents"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:logs:*:*:*"
        }
    ]
} 

请参阅以下AWS文档有关更多详细信息,请
http://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambd前奏角色

Please refer to the following AWS documentation for more details http://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role

这篇关于无法使AWS Lambda函数登录(文本输出)到CloudWatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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