This article gives you the guideline to setup how to configure webhook in CloudWatch by using Lambda and EventBridge.
EventBridge delivers a stream of real-time data from your applications, software as a service (SaaS) applications, and AWS services to targets such as AWS Lambda functions, HTTP invocation endpoints using API destinations, or event buses in other AWS accounts.
Lambda is used to stream event from CloudWatch to Cloud Alert.
EventBridge was formerly called Amazon CloudWatch Events. The default event bus and the rules you created in CloudWatch Events also display in the EventBridge console. EventBridge uses the same CloudWatch Events API, so your code that uses the CloudWatch Events API stays the same. New features added to EventBridge are not added to CloudWatch Events.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html
Configuration step by step
Step 1: Setup monitor on CloudWatch
Configure monitor by Create Alarm (push message to AWS Lambda)
Create Alarm > Select metric (E.g: EC2 - set CPU Utilization)
Configure Lambda to receive message from AWS SNS.
Step 2: Create a new lambda function
Fill function name and select Python 3.9
Download zip file from here
Click to Upload From > .zip file and select file downloaded from previous step
Go to Configuration > Add Environment variables
Step 3: Create new EventBridge
Fill name and select Event Pattern
Select target lambda function created from previous step
Appendix: Supported event from AWS
Many AWS services generate events that EventBridge receives. When an AWS service in your account emits an event, it goes to your account’s default event bus.
The following table shows AWS services that generate events. Choose the service name to see more information about how that service and EventBridge work together.
Service | Delivery type |
---|---|
Amazon AppFlow | Best effort |
Application Auto Scaling | Best effort |
AWS Application Cost Profiler | Best effort |
Amazon Athena | Best effort |
AWS Backup | Best effort |
AWS Batch | Guaranteed |
Amazon Braket | Guaranteed |
AWS Certificate Manager Private Certificate Authority | Best effort |
Amazon Chime | Best effort |
Events from AWS CloudTrail | Best effort |
Amazon CloudWatch | Guaranteed |
AWS CodeArtifact | Guaranteed |
AWS CodeBuild | Best effort |
AWS CodeCommit | Best effort |
AWS CodeDeploy | Best effort |
AWS Config | Best effort |
Amazon Connect | Best effort |
AWS Control Tower | Best effort |
AWS Data Exchange | Best effort |
Amazon Data Lifecycle Manager | Best effort |
AWS DataSync | Best effort |
Amazon DevOps Guru | Best effort |
AWS Elastic Beanstalk | Best effort |
Amazon Elastic Block Store | Best effort |
Amazon Elastic Block Store volume modifications | Best effort |
Amazon Elastic Compute Cloud (Amazon EC2) | Best effort |
Amazon EC2 Auto Scaling | Best effort |
Amazon EC2 Fleets | Best effort |
Amazon EC2 Spot Instance Interruption | Best effort |
Amazon Elastic Container Registry | Best effort |
Amazon Elastic Container Service | Guaranteed |
AWS Elemental MediaConvert | Guaranteed |
AWS Elemental MediaLive | Best effort |
AWS Elemental MediaPackage | Best effort |
AWS Elemental MediaStore | Guaranteed |
Amazon EMR | Best effort |
Amazon EventBridge scheduled rules | Guaranteed |
Amazon GameLift | Best effort |
AWS Glue | Best effort |
AWS Glue DataBrew | Best effort |
AWS Ground Station | Best effort |
AWS Health | Best effort |
Amazon Inspector | Best effort |
Amazon Interactive Video Service | Best effort |
AWS IoT Analytics | Guaranteed |
AWS IoT Greengrass V1 | Best effort |
AWS IoT Greengrass V2 | Best effort |
AWS Key Management Service CMK deletion | Guaranteed |
AWS Key Management Service CMK rotation | Best effort |
AWS Key Management Service imported key material expiration | Best effort |
Amazon Location Service | Guaranteed |
Amazon Macie | Best effort |
Amazon Managed Blockchain | Best effort |
AWS Managed Services | Best effort |
AWS OpsWorks | Guaranteed |
AWS Proton | Best effort |
Amazon QLDB | Guaranteed |
Amazon RDS | Best effort |
Amazon Redshift | Guaranteed |
AWS Resource Access Manager | Best effort |
Savings Plans | Best effort |
AWS Security Hub | Guaranteed |
AWS Signer | Guaranteed |
Amazon Simple Storage Service (Amazon S3) | Guaranteed |
Amazon Simple Workflow Service | Best effort |
AWS Step Functions | Best effort |
AWS Storage Gateway | Guaranteed |
AWS Support | Best effort |
AWS Systems Manager | Best effort |
Tag changes on resources | Best effort |
AWS Transit Gateway | Best effort |
Amazon Translate | Guaranteed |
AWS Trusted Advisor | Best effort |
Amazon WorkSpaces | Best effort |
Each AWS service that generates events sends them to EventBridge as either best effort or guaranteed delivery. Best effort delivery means that the service attempts to send all events to EventBridge, but in some rare cases an event might not be delivered. Guaranteed delivery means that all events from the service are successfully delivered to EventBridge.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html