Account level alerting using Amazon CloudWatch, AWS Lambda and Amazon SNS

Amazon CloudWatch → AWS Lambda → Amazon SNS

Creates alerting system at account level which triggers Lambda function which can parse and publish a SNS notification

This sample project showcases a centralized alerting system that leverages CloudWatch Logs Subscription filters and Lambda functions to trigger SNS notifications when a specified pattern is matched across any CloudWatch log group within the account. This robust solution enables comprehensive monitoring and proactive alerting, ensuring timely identification and mitigation of critical events or errors
The core components of this pattern include a CloudWatch Logs Account-level Subscription filter, which monitors log events across the entire account, and a notification Lambda function. This function is triggered by the Subscription filter and responsibly publishes relevant details, such as log group name, log stream name, and the matched log event, to the SNS topic, ensuring that stakeholders receive comprehensive and actionable information.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/cloudwatch-account-subscription-Lambda-sns-notification

Deploy

sam buildsam deploy --guided --parameter-overrides EmailAddress='example.your@mail.com' LambdaFunctionName='NotificationLambda'


Testing

To test this pattern, which monitors all log groups for the 'Exception' pattern and sends SNS notifications, follow these steps:
1. Choose an application generating logs in your AWS account.
2. Intentionally introduce an exception or error condition that logs an 'Exception' message.
3. Verify the log event containing 'Exception' is written to CloudWatch Logs.
4. Monitor for an SNS email notification containing details like the log group name, log stream name, and the log event with the 'Exception' pattern.
This pattern automatically monitors new log groups created, ensuring comprehensive coverage across your AWS account.

Cleanup

Delete the stack: cdk delete.

Created by:

Shubham More

Shubham More

Cloud Support Engineer - SVLS

Follow on LinkedIn