Cloud Alert – CloudWatch Event Setting guideline

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)

Setup EC2 with alert high CPU Usage > choose Per-Instance Metrics > configure a instance have metric name is "CPU Utilization"
Specify metric and conditions: Define the threshold CPU value > 80
Configure actions: Define AWS SNS to receive the notification
Finally, Add Alarm name & description. End Create Alarm.

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

Build event pattern

Select target lambda function created from previous step

Additional settings
Next, Add tags & Create Rule. Finish!

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.

ServiceDelivery type
Amazon AppFlowBest effort
Application Auto ScalingBest effort
AWS Application Cost ProfilerBest effort
Amazon AthenaBest effort
AWS BackupBest effort
AWS BatchGuaranteed
Amazon BraketGuaranteed
AWS Certificate Manager Private Certificate AuthorityBest effort
Amazon ChimeBest effort
Events from AWS CloudTrailBest effort
Amazon CloudWatchGuaranteed
AWS CodeArtifactGuaranteed
AWS CodeBuildBest effort
AWS CodeCommitBest effort
AWS CodeDeployBest effort
AWS ConfigBest effort
Amazon ConnectBest effort
AWS Control TowerBest effort
AWS Data ExchangeBest effort
Amazon Data Lifecycle ManagerBest effort
AWS DataSyncBest effort
Amazon DevOps GuruBest effort
AWS Elastic BeanstalkBest effort
Amazon Elastic Block StoreBest effort
Amazon Elastic Block Store volume modificationsBest effort
Amazon Elastic Compute Cloud (Amazon EC2)Best effort
Amazon EC2 Auto ScalingBest effort
Amazon EC2 FleetsBest effort
Amazon EC2 Spot Instance InterruptionBest effort
Amazon Elastic Container RegistryBest effort
Amazon Elastic Container ServiceGuaranteed
AWS Elemental MediaConvertGuaranteed
AWS Elemental MediaLiveBest effort
AWS Elemental MediaPackageBest effort
AWS Elemental MediaStoreGuaranteed
Amazon EMRBest effort
Amazon EventBridge scheduled rulesGuaranteed
Amazon GameLiftBest effort
AWS GlueBest effort
AWS Glue DataBrewBest effort
AWS Ground StationBest effort
AWS HealthBest effort
Amazon InspectorBest effort
Amazon Interactive Video ServiceBest effort
AWS IoT AnalyticsGuaranteed
AWS IoT Greengrass V1Best effort
AWS IoT Greengrass V2Best effort
AWS Key Management Service CMK deletionGuaranteed
AWS Key Management Service CMK rotationBest effort
AWS Key Management Service imported key material expirationBest effort
Amazon Location ServiceGuaranteed
Amazon MacieBest effort
Amazon Managed BlockchainBest effort
AWS Managed ServicesBest effort
AWS OpsWorksGuaranteed
AWS ProtonBest effort
Amazon QLDBGuaranteed
Amazon RDSBest effort
Amazon RedshiftGuaranteed
AWS Resource Access ManagerBest effort
Savings PlansBest effort
AWS Security HubGuaranteed
AWS SignerGuaranteed
Amazon Simple Storage Service (Amazon S3)Guaranteed
Amazon Simple Workflow ServiceBest effort
AWS Step FunctionsBest effort
AWS Storage GatewayGuaranteed
AWS SupportBest effort
AWS Systems ManagerBest effort
Tag changes on resourcesBest effort
AWS Transit GatewayBest effort
Amazon TranslateGuaranteed
AWS Trusted AdvisorBest effort
Amazon WorkSpacesBest 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

Leave a Reply