Monitoring CPU RAM HDD EC2 instance and alert the alarm to MS-Team
AWS offers many services to manage your infrastructure as well as the monitoring what happening with the services. You can alert the error message either to Email or SMS or other services.
Use case : In the real scenario, your company or organization would like to monitor the EC2 instances CUP / RAM / HDD. In case those spike up or high usage, you would like to notify the alarm message to your team member via email, sms or MS-Team.
What is the solution we can achieve this use case?
I would like to share my solution how to build AWS cloudwatch Event monitoring and alert the alarm message to SNS and push the message to MS-Team.
In this article you will learn how to use the following services.
- Cloudwatch Event
- Lambda function with python script
- MS-Team webhook API
1.CloudWatch Event will listen to any EC2 instances CUP/RAM/HDD check if it is over unit we set in cloudwatch alarm
2.When Cloudwatch Event happen, it will trigger the send SNS notification
3.Then SNS will broadcast the message to all subscribers such as SMS/Email/Lambda
4.The subscriber Lambda will process the logic to get the all information and send to MS-Team Group different channel base on the logic
5.The app team members will receive the message
create SNS toptic and add all subscriptions
Create Cloud Watch Event
Here is python script with environment variables HOOK_URL , and ENV
Creating webhook : see this blog https://medium.com/javarevisited/trigger-the-alert-message-to-ms-team-using-aws-sns-and-lambda-function-1c7769012eff
If this article is helpful, please support to help sharing with other readers to reach this story as well.