Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudWatch logs delayed for a lambda function

It seems that I have a delay with the CloudWatch log of one of my lambda function's. I have a lambda function that gets triggered by a Kinesis stream. The lambda function writes records into a DynamoDB table.

I know for sure that the lambda function gets executed since I see new records in the DynamodDB table. But the CloudWatch log doesn't get updated. I waited for almost an hour and there is no update.

Also, permissions are good since I have older records in my log.

Any idea ?

like image 402
kord Avatar asked Jan 28 '18 22:01

kord


People also ask

How do I integrate Cloudwatch Logs with Lambda?

Lambda automatically integrates with CloudWatch Logs and pushes all logs from your code to a CloudWatch Logs group associated with a Lambda function, which is named /aws/lambda/ <function name> .

How do I log to CloudWatch using awslambdabasicexecutionrole?

The AWSLambdaBasicExecutionRole managed policy contains the following statement that allows our function to log to CloudWatch: In the browser tab of the lambda function, click on the Monitor tab and select View logs in CloudWatch Click on the most recent log stream and you should see the logs of your lambda function

How do I view logs for lambda functions in AWS?

You can view logs for Lambda functions using the Lambda console, the CloudWatch console, the AWS Command Line Interface (AWS CLI), or the CloudWatch API. This page describes how to view logs using the Lambda console.

How do I add logging to my Lambda code?

You can insert logging statements into your code to help you validate that your code is working as expected. Lambda automatically integrates with CloudWatch Logs and pushes all logs from your code to a CloudWatch Logs group associated with a Lambda function, which is named /aws/lambda/ <function name> .


1 Answers

CloudWatch does sometimes have a slight delay, but if you've waited an hour, it probably isn't going to show up. Double-check permissions to ensure they haven't changed. From the Lambda Management Console, do you still see "Amazon CloudWatch Logs" on the right as seen in the picture below?

enter image description here

If not, double check your security policy to make sure you have allowed CreateLogGroup, CreateLogStream, and PutLogEvents. Here is a snippet of a policy that includes the appropriate permissions.

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

Hope this helps!

like image 159
Parrett Apps Avatar answered Oct 28 '22 05:10

Parrett Apps