Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CloudWatch logs: How to send an email notification when particular error message is logged by lambda

I have to monitor CloudWatch logs for particular lambda. When the specific error message such as HTTP-50X is logged to CloudWatch, then we need to send an email notification to alert that the something is wrong.

We need help to create alert email in AWS to monitor manually the logs to see if there is any such error logged.

like image 509
user79319 Avatar asked May 24 '20 00:05

user79319


2 Answers

This is exactly what metric filter is for. Create a metric filter that monitors your log group for specific pattern. Then create a CloudWatch alarm based on a new metric and configure it with an SNS action. Then simply subscribe your email to that SNS topic.

All of this can be easily done via CloudFormation(Metric filter, Alarm, SNS). You can also use CDK.

like image 68
Tofig Hasanov Avatar answered Oct 01 '22 08:10

Tofig Hasanov


You can process/monitor logs in real-time using lambda functions. Checkout Using AWS Lambda with Amazon CloudWatch Logs and Real-time Processing of Log Data with Subscriptions for details.

like image 42
jellycsc Avatar answered Oct 01 '22 10:10

jellycsc