Logo

dev-resources.site

for different kinds of informations.

CloudWatch CPU Utilization Monitoring with SNS Alert

Published at
9/4/2024
Categories
cloudwatch
cpuutilization
snsalert
monitoring
Author
mahpara_jabbar_0521a5b816
Author
25 person written this
mahpara_jabbar_0521a5b816
open
CloudWatch CPU Utilization Monitoring with SNS Alert

This lab focuses on setting up a CloudWatch alarm to monitor CPU utilization on an EC2 instance, configuring an SNS topic to receive email alerts when CPU utilization exceeds a defined threshold, and creating a CloudWatch dashboard for real-time monitoring. Additionally, it involves installing the stress tool on the EC2 instance to simulate high CPU usage for testing the alarm and notification system.

Summary

  • Launch EC2 Instance.
  • Create SNS Topic and Subscription.
  • Create a CloudWatch Alarm.
  • Create a CloudWatch Dashboard.
  • Connect to EC2 and Install Stress Tool.

Launch EC2 Instance:

Launch an EC2 instance with the following specifications:

  • Instance Type: t2.nano
  • Network: Assign a public IP.
  • Security Group: Allow SSH (port 22) from your IP.

Image description

Create SNS Topic and Subscription:

  • Go to the SNS (Simple Notification Service) section in the AWS Management Console.
  • Click on Topics > Create Topic.
  • Choose Standard as the type.
  • Provide a Name for the topic (e.g., EC2-CPU-Alerts).
  • Click Create Topic.

Image description

  • In the newly created topic, click on Create Subscription.
  • Set the protocol to Email.
  • Enter your email address and click Create Subscription.
  • Confirm the subscription by checking your email and clicking on the verification link.

Create a CloudWatch Alarm:

  • Go to the CloudWatch section in the AWS Management Console.
  • Select Alarms from the sidebar, then click Create Alarm.
  • Click Select Metric.
  • Navigate to EC2 > Per-Instance Metrics > CPUUtilization.
  • Choose the Instance ID of your EC2 instance.
  • Set the Statistic to Average and the Period to 1 minute.
  • Set the Threshold Type to Static and enter 60 as the value (for greater than 60% CPU utilization).
  • Click Next.
  • Under Actions, choose Select an existing SNS topic and pick the topic you created earlier.
  • Click Next.
  • Provide an Alarm Name (e.g., High-CPU-Utilization-Alarm).
  • Click Create Alarm.

Image description

Create a CloudWatch Dashboard:

  • In the CloudWatch console, navigate to Dashboards.
  • Click Create Dashboard.
  • Provide a Name for the dashboard (e.g., EC2-Monitoring-Dashboard).
  • Click Add Widget.
  • Choose Line and click Configure.
  • Select the same metric used in your alarm (EC2 CPU Utilization).
  • Click Create Widget.
  • Save the dashboard.

Image description

Connect to EC2 and Install Stress Tool:

  • Connect your EC2 instance.
  • Run the following commands to update the instance and install the stress tool:
  • sudo yum update -y
  • sudo yum install stress -y
  • Use the stress tool to generate CPU load:
  • stress --cpu 1 --timeout 300

Image description

CPU utilization crosses the threshold:

Image description

Alarm Generated:

Image description

This lab should give you a hands-on understanding of setting up CloudWatch alarms with SNS and monitoring an EC2 instance's CPU utilization.

cloudwatch Article's
30 articles in total
Favicon
Monitoring AWS Infrastructure: Building a Real-Time Observability Dashboard with Amazon CloudWatch and Prometheus
Favicon
A Simple Guide to AWS Monitoring Tools
Favicon
Config AWS Cloudwatch Application Signals Transaction Search with CDK
Favicon
Quickly and easily filter your Amazon CloudWatch logs using Logs Insights
Favicon
Forward logs to Cloudwatch for an EC2 instance running a custom Linux AMI
Favicon
AWS CloudWatch: Implementing Data Protection Policy for Sensitive Log Data!
Favicon
Config AWS Cloudwatch Application Signals for NodeJs Lambda with CDK
Favicon
AWS CloudWatch Logging and Live Tail using AWS CLI!
Favicon
AWS CloudWatch Logging and Live Tail using Python/Boto3 SDK!
Favicon
A Beginner’s Guide to Amazon CloudWatch: Monitoring Your Cloud Like a Pro
Favicon
Automatização de Reboots de Instâncias EC2 com CloudWatch, EventBridge e Lambda
Favicon
Streaming of Desktop Applications Securely on Web Browser Using Amazon AppStream 2.0
Favicon
How to Use Send AWS CloudWatch Metrics to GreptimeCloud by Grafana Alloy
Favicon
AWS CloudWatch Logging and Live Tail!
Favicon
Understanding Logging in Kubernetes - From Containers to Nodes
Favicon
AWS CloudWatch Observability Solutions: Game-Changer or Just a Glossy Wrapper? Honest First Impressions!
Favicon
AWS Lambda Log Aggregation Using CloudWatch Custom Log Group & Logs Insights!
Favicon
AWS Logging, Monitoring & Auditing with AWS CloudWatch and CloudTrail!
Favicon
Amazon CloudWatch Internet Monitor from Amazon Network Load balancer
Favicon
AWS Monitoring - Part 1: AWS CloudWatch
Favicon
AWS Database Migration Service now includes enhanced monitoring dashboard for your DMS tasks
Favicon
CloudWatch CPU Utilization Monitoring with SNS Alert
Favicon
VPC Flow Logs Setup
Favicon
Transfer of Data Across Accounts from S3 to S3 Using AWS DataSync
Favicon
Real-Time Incident Recovery with Event-Driven Microservices Architecture and Early Monitoring
Favicon
Implementing SLO Error Budget Monitoring with AWS Services Only
Favicon
Gerenciamento de alta latência com AWS CloudWatch e AWS Systems Manager
Favicon
Creating Recommended Alarms for Amazon OpenSearch Service with Terraform
Favicon
Automate EC2 Instance Management with AWS Lambda
Favicon
Deep Dive on AWS Clean Rooms with Integration to AWS Glue

Featured ones: