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
So the behavior I observed was.. I had all the right permissions.. I had logs of the
START
andEND
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.Some ideas about what you could check (sorry if you’ve already checked):
Check that your Lambda has permissions to write logs on CloudWatch (it should have permissions for
logs:CreateLogGroup
,logs:CreateLogStream
andlogs:PutLogEvents
which are the allowed actions for theAWSLambdaBasicExecutionRole
role) (visible on the Configuration > Permissions > Resource summary tab).Check that you have
START
andEND
messages (with the sameRequestId
as the one in theREPORT
message you’ve pasted), and that you have no logs between those (logging tostdout
throughconsole.log
makes usually your logs appear between those).