skip to Main Content

I have a lambda that I can see is pushings logs to cloudwatch, it is in test mode still..

exports.handler = async (event, context) => {
    console.log("TESTING 123");
    
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    
    console.log(response)
    
    return context.logStreamName;
};
    

I was expecting to get to iterate in here with the logs and kind of confirm things that way.. but when I goto the logs they do not have my console output.

2022-07-13T17:22:54.170Z
UUID123
2022/07/13/[$LATEST]UUID123
1.19
2
@billedDuration
2.0
@duration
1.19
@ingestionTime
UUID123
@log
UUID123:/aws/lambda/my-test-lambda
@logStream
2022/07/13/[$LATEST]UUID123
@maxMemoryUsed
5.8E7
@memorySize
1.28E8
@message
REPORT RequestId: some-id-123 Duration: 1.19 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 58 MB
@requestId
UUID123
@timestamp
123
@type
REPORT

2

Answers


  1. Chosen as BEST ANSWER

    So the behavior I observed was.. I had all the right permissions.. I had logs of the START and END coming through.. I even tried wiping the lambda and starting over with good permissions incase it was the loggroup created by myself manually..

    in the end what jump started my logs was hitting Deploy in the GUI once... After that first deploy suddenly all my logs started to pop up in the cloudwatch and monitoring sections.. very strange but.. well now I know and hopefully save someone else from scratching their heads.


  2. Some ideas about what you could check (sorry if you’ve already checked):

    1. Check that your Lambda has permissions to write logs on CloudWatch (it should have permissions for logs:CreateLogGroup, logs:CreateLogStream and logs:PutLogEvents which are the allowed actions for the AWSLambdaBasicExecutionRole role) (visible on the Configuration > Permissions > Resource summary tab).

    2. Check that you have START and END messages (with the same RequestId as the one in the REPORT message you’ve pasted), and that you have no logs between those (logging to stdout through console.log makes usually your logs appear between those).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search