Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding logs for lambda function errors in AWS Cloudwatch?

I'm going to profess that I have not actually started deploying AWS Lambda functions yet, but this article says this:

The logs on AWS CloudWatch are horrible. It took me an eternity to find failing functions for simple applications, imagine the horror with large scale applications.

Is there something particularly hard about filtering the log on AWS Cloudwatch? For example if we deploy the stock hello lambda from Servless's node template I imagine that it's fairly easy to find the invocations (Error or otherwise) in the log?

If anyone has any simple best practice tips that we can follow to make the log statements easy to find that would be awesome!

like image 610
Ole Avatar asked Nov 08 '22 06:11

Ole


1 Answers

IMO – CloudWatch Logs are perfectly fine for most Serverless applications. You can access them via serverless logs on the client, or via the AWS Console.

The main thing you can do to make your life easier is to log at various levels (via console.log, console.info, console.warn and console.error) to allow you to separate different kinds of error messages out further down the line, and to attach some metadata to each log line – e.g. the ID of the thing you're operating on.

Winston is a library that can make this process easier for you.

like image 187
Josh McMillan Avatar answered Nov 09 '22 22:11

Josh McMillan