Monitoring CPU RAM HDD EC2 instance and alert the alarm to MS-Team

sophea Mak
3 min readMay 20, 2021

--

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
  • SNS
  • Lambda function with python script
  • MS-Team webhook API
system diagram

Workflow:

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

create SNS toptic and add all subscriptions

Create Cloud Watch Event

Lambda function

Here is python script with environment variables HOOK_URL , and ENV

MS-Team :

Creating webhook : see this blog https://medium.com/javarevisited/trigger-the-alert-message-to-ms-team-using-aws-sns-and-lambda-function-1c7769012eff

In Conclusion

If this article is helpful, please support to help sharing with other readers to reach this story as well.

--

--

sophea Mak
sophea Mak

Written by sophea Mak

15+ years of professional experience engineer software development with JAVA and open-source majority and DevOps lately. https://www.linkedin.com/in/sopheamak

No responses yet