In my foray into cloud computing, I have decided to try out different things and document them in an article. My first article will be focused on sending CloudWatch notifications to a Slack workspace using the Slack Webhook and AWS Lambda function. The AWS Services that will be used to achieve this include an EC2 instance, CloudWatch, AWS SNS(Simple Notification Service) , Lambda & AWS Systems Manager Parameter Store.
Amazon CloudWatch is a tool that captures all the information necessary to track the performance of all applications hosted in the AWS cloud. CloudWatch tracks measures like latency, request count, application logs, CPU usage, & other custom metrics. CloudWatch logs are captured in near-real-time and CloudWatch **_Alarms _**can be used to watch your metrics against a specified threshold and proactively make decisions like trigger an EC2 instance to auto-shutdown when the CPU usage crosses a particular threshold.
The EC2 instance will periodically send its CPU usage to CloudWatch. Once the CPU usage crosses a particular threshold (40%), the CloudWatch alarm goes from “OK” to “In Alarm”. When this happens, a message is sent to an SNS topic which in turn triggers a lambda function that retrieves the pre-saved slack webhook URL from SSM Parameter Store and sends a notification to the slack workspace.
Architecture for creating slack notifications from CloudWatch
#slackbot #aws #cloud-computing #cloudwatch #aws-lambda