Alternatively, you can create a CloudWatch alarm with the command below from the command line interface.
This is because it has not collected enough data from the running instance. When you create the alarm, you will notice that it has a status if “Insufficient Data”. 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. Once the CPU usage crosses a particular threshold (40%), the CloudWatch alarm goes from “OK” to “In Alarm”. The EC2 instance will periodically send its CPU usage to CloudWatch. 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. CloudWatch tracks measures like latency, request count, application logs, CPU usage, & other custom metrics. AWS CloudWatchĪmazon CloudWatch is a tool that captures all the information necessary to track the performance of all applications hosted in the AWS cloud.
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. My first article will be focused on sending CloudWatch notifications to a Slack workspace using the Slack Webhook and AWS Lambda function. In my foray into cloud computing, I have decided to try out different things and document them in an article. Generating Slack Notifications from AWS CloudWatch Alarms