wawawa
wawawa

Reputation: 3355

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:

enter image description here

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? (I thought it'll be automatical...)

Upvotes: 3

Views: 8646

Answers (4)

Ping Woo
Ping Woo

Reputation: 1773

You have to add action

        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }

to your lambda role policy

Upvotes: 0

John Rotenstein
John Rotenstein

Reputation: 270089

Your AWS Lambda function needs the following permissions to access 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.

Upvotes: 7

Traycho Ivanov
Traycho Ivanov

Reputation: 3217

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.

Upvotes: -1

Mark B
Mark B

Reputation: 200998

The most common cause of this problem is that you have not assigned an IAM role to your Lambda function that has permission to create logs in CloudWatch.

Upvotes: 4

Related Questions