βοΈ AWS CloudWatch Deep Dive | Monitor EC2, Logs, Metrics & CPU Alerts with SNS π¨
Beginner-friendly notes on AWS CloudWatch with practical EC2 CPU monitoring and email alerts using Amazon SNS.

π Table of Contents
What is AWS CloudWatch?
Why Do We Need CloudWatch?
Main Components of CloudWatch
CloudWatch Metrics
CloudWatch Logs and Log Groups
CloudWatch Alarms
What is Amazon SNS?
CloudWatch + SNS Architecture
Practical Project: EC2 CPU Alert
Step-by-Step Implementation
Testing the Alarm
Important CloudWatch Concepts
Default vs Custom Metrics
Common Use Cases
Best Practices
Interview Questions and Answers
Key Takeaways
1οΈβ£ What is AWS CloudWatch?
Amazon CloudWatch is a monitoring and observability service provided by AWS.
It helps us monitor:
π₯οΈ EC2 instances
π CPU utilization
πΎ Memory and disk usage
π Application logs
π AWS services
π¨ Infrastructure problems
π© Alerts and notifications
In simple words:
CloudWatch helps us understand what is happening inside our AWS infrastructure.
For example, imagine you have an EC2 server running your application.
You may want to know:
Is the server running?
Is CPU usage too high?
Is the application generating errors?
Is disk space running out?
Has the server stopped responding?
CloudWatch helps you monitor these things.
2οΈβ£ Why Do We Need CloudWatch?
Without monitoring, we may only discover a problem after users complain.
For example:
Application becomes slow
β
Users face problems
β
Users complain
β
Team starts investigating
This is called reactive monitoring.
With CloudWatch:
Application
β
CloudWatch monitors metrics
β
Threshold is crossed
β
CloudWatch Alarm
β
SNS Notification
β
DevOps Team receives alert
This allows the team to identify problems quickly.
3οΈβ£ Main Components of AWS CloudWatch
The major components are:
| Component | Purpose |
|---|---|
| π Metrics | Numerical performance data |
| π Logs | Application and system logs |
| π¨ Alarms | Trigger actions when thresholds are crossed |
| π Dashboards | Visual monitoring of resources |
| π Events / Rules | Respond to changes and events |
The most important concepts for beginners are:
Metrics β Monitoring Data
Logs β Application/System Records
Alarms β Alert when something goes wrong
SNS β Send notifications
4οΈβ£ What Are CloudWatch Metrics? π
A metric is a numerical measurement that represents the performance or behavior of a resource.
For example:
CPU Utilization = 75%
Network In = 100 MB
Disk Usage = 80%
Number of Requests = 5,000
AWS automatically provides many default metrics for its services.
For an EC2 instance, some common metrics are:
CPUUtilization
NetworkIn
NetworkOut
DiskReadOps
DiskWriteOps
StatusCheckFailed
Example:
CPU Utilization
10:00 β 20%
10:05 β 35%
10:10 β 70%
10:15 β 90%
If CPU reaches a dangerous level, CloudWatch can trigger an alarm.
5οΈβ£ CloudWatch Logs π
Logs contain information about events happening inside applications and systems.
For example:
Application started
User login successful
Database connection failed
API request received
Application error occurred
CloudWatch Logs allows us to collect and store these logs in AWS.
A common structure is:
CloudWatch Logs
β
βββ Log Group
β
βββ Log Stream
βββ Log Stream
βββ Log Stream
What is a Log Group?
A Log Group is a collection of related logs.
Example:
/aws/codebuild/my-project
This log group may contain logs generated by a CodeBuild project.
Another example:
/application/backend
Inside the Log Group, multiple Log Streams can exist.
6οΈβ£ What Are CloudWatch Alarms? π¨
A CloudWatch Alarm watches a metric and performs an action when a condition is met.
For example:
IF CPU Utilization > 80%
FOR 5 minutes
THEN
Send Email Alert
The flow looks like:
EC2 Instance
β
CPU Metric
β
CloudWatch
β
CloudWatch Alarm
β
Amazon SNS
β
π§ Email Notification
7οΈβ£ What is Amazon SNS? π
Amazon Simple Notification Service (SNS) is a messaging and notification service.
SNS can send notifications through:
π§ Email
π± SMS
π HTTP/HTTPS endpoints
π² Mobile notifications
AWS Lambda
Other AWS services
In this project, SNS will send an email notification when CPU usage crosses the configured threshold.
8οΈβ£ CloudWatch + SNS Architecture
The architecture for this project is simple:
βββββββββββββββββββ
β EC2 Instance β
β β
β CPU Usage β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β CloudWatch β
β β
β Metrics β
ββββββββββ¬βββββββββ
β
CPU > Threshold
β
βΌ
βββββββββββββββββββ
β CloudWatch Alarmβ
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Amazon SNS β
ββββββββββ¬βββββββββ
β
βΌ
π§ Email Alert
9οΈβ£ Practical Project π
Project: Monitor EC2 CPU Utilization and Send Email Alerts
In this project, we will:
Launch an EC2 instance.
Monitor its CPU utilization.
Create an SNS Topic.
Subscribe an email address.
Create a CloudWatch Alarm.
Set a CPU threshold.
Generate CPU load.
Trigger the alarm.
Receive an email notification.
π Prerequisites
Before starting, you need:
An AWS Account
Basic knowledge of EC2
An EC2 instance
Permission to access CloudWatch and SNS
An active email address
Step 1οΈβ£ Launch an EC2 Instance π₯οΈ
Go to:
AWS Console
β EC2
β Launch Instance
For learning purposes, you can select:
AMI: Ubuntu
Instance Type:
t2.micro / t3.micro
Configure the required settings and launch the instance.
After launching:
EC2 Dashboard
β
Instances
β
Select your instance
Make sure the instance state is:
Running
Step 2οΈβ£ Check EC2 Metrics in CloudWatch π
Go to:
AWS Console
β CloudWatch
β Metrics
Then navigate to:
AWS Namespaces
β EC2
β Per-Instance Metrics
Select your EC2 instance.
You should see metrics such as:
CPUUtilization
NetworkIn
NetworkOut
DiskReadOps
DiskWriteOps
Select:
CPUUtilization
You will now see a graph showing the CPU usage of your EC2 instance.
Step 3οΈβ£ Create an SNS Topic π
Go to:
AWS Console
β Amazon SNS
β Topics
β Create Topic
Choose:
Type: Standard
Example:
Name:
EC2-CPU-Alert
Then click:
Create Topic
Step 4οΈβ£ Create an SNS Subscription π§
After creating the topic:
SNS Topic
β Create Subscription
Select:
Protocol:
Email
Enter your email address.
For example:
your-email@example.com
Click:
Create Subscription
AWS will send a confirmation email.
Open the email and click:
Confirm Subscription
Your subscription should now show:
Status: Confirmed
β οΈ Important: If you do not confirm the subscription, SNS will not send notifications to your email.
Step 5οΈβ£ Create a CloudWatch Alarm π¨
Go to:
CloudWatch
β Alarms
β Create Alarm
Click:
Select Metric
Navigate to:
EC2
β Per-Instance Metrics
β CPUUtilization
Select your EC2 instance.
Step 6οΈβ£ Configure the Alarm Condition
For example:
Threshold Type:
Static
Set the condition:
CPUUtilization > 70%
You can configure:
Whenever CPUUtilization is...
Greater than 70
Example:
CPU Usage: 20% β OK
CPU Usage: 50% β OK
CPU Usage: 75% β ALARM π¨
Step 7οΈβ£ Configure the Alarm Action
When the alarm enters the ALARM state, select:
Send notification to:
EC2-CPU-Alert
This connects:
CloudWatch Alarm
β
SNS Topic
β
Email
Step 8οΈβ£ Name the Alarm
Example:
Alarm Name:
High-EC2-CPU-Utilization
You can also add a description:
This alarm monitors EC2 CPU utilization and sends an SNS notification when CPU usage exceeds 70%.
Click:
Create Alarm
Initially, the alarm state may show:
Insufficient Data
After CloudWatch receives enough metric data, it will change to:
OK
1οΈβ£1οΈβ£ How to Test the CloudWatch Alarm π§ͺ
Now we need to increase the CPU usage of the EC2 instance.
First, connect to your EC2 instance:
ssh -i key.pem ubuntu@<EC2-PUBLIC-IP>
Install a CPU stress tool:
sudo apt update
sudo apt install stress -y
Generate CPU load:
stress --cpu 2 --timeout 300
This command will:
Generate CPU Load
β
Increase CPU Utilization
β
CloudWatch detects metric change
β
Threshold crossed
β
Alarm changes to ALARM
β
SNS sends Email π¨
After the configured evaluation period, you should receive an email notification.
Example:
Subject:
ALARM: High-EC2-CPU-Utilization
Congratulations! π
You have successfully created an automated AWS monitoring and alerting system.
1οΈβ£2οΈβ£ Understanding CloudWatch Alarm States
CloudWatch alarms generally have three states.
π’ OK
Everything is working normally.
Example:
CPU = 25%
π΄ ALARM
The configured threshold has been crossed.
Example:
CPU > 70%
The configured action is triggered.
π‘ INSUFFICIENT_DATA
CloudWatch does not have enough data to determine the alarm state.
This may happen when:
The instance was recently launched.
Metrics are not available yet.
The monitoring configuration changed.
1οΈβ£3οΈβ£ Default Metrics vs Custom Metrics
Default Metrics
AWS automatically provides metrics for many AWS services.
Examples:
EC2 CPU Utilization
Network In
Network Out
You do not need to manually configure these basic metrics.
Custom Metrics
Sometimes AWS does not provide the exact metric you need.
For example:
Application Response Time
Custom Business Metrics
Number of Active Users
Memory Usage
Disk Usage
In such cases, you can send custom data to CloudWatch.
Example architecture:
Application
β
CloudWatch Agent
β
CloudWatch Custom Metric
β
CloudWatch Alarm
β
SNS Notification
1οΈβ£4οΈβ£ Important EC2 Metrics
Here are some useful EC2 metrics:
| Metric | Description |
|---|---|
| CPUUtilization | Percentage of CPU usage |
| NetworkIn | Incoming network traffic |
| NetworkOut | Outgoing network traffic |
| DiskReadOps | Number of disk read operations |
| DiskWriteOps | Number of disk write operations |
| StatusCheckFailed | Indicates instance health issues |
1οΈβ£5οΈβ£ CloudWatch Logs Example
Suppose your application generates logs like:
INFO: Application Started
INFO: Database Connected
ERROR: Database Connection Failed
ERROR: API Request Failed
Instead of manually logging into the server and checking:
/var/log/
You can send these logs to:
Amazon CloudWatch Logs
This allows centralized monitoring.
1οΈβ£6οΈβ£ Real-World DevOps Monitoring Architecture
In a production environment, monitoring may look like:
Application
β
ββββββββββββββββΌβββββββββββββββ
β β β
βΌ βΌ βΌ
Metrics Logs Events
β β β
ββββββββββββββββΌβββββββββββββββ
βΌ
CloudWatch
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
Alarms Dashboards
β
βΌ
SNS
β
βββββββ΄ββββββ
βΌ βΌ
Email Slack
1οΈβ£7οΈβ£ Common Use Cases of CloudWatch
CloudWatch can be used for:
π₯οΈ EC2 Monitoring
Monitor:
CPU
Memory
Disk
Network
π Application Logs
Monitor:
Errors
Warnings
Application Events
π¨ Automated Alerts
Send alerts when:
CPU is too high
Disk is almost full
Application is failing
EC2 instance is unhealthy
π Dashboards
Create dashboards to visualize:
Infrastructure Health
Application Performance
Resource Utilization
Errors
1οΈβ£8οΈβ£ Best Practices π‘
1. Avoid Monitoring Everything
Focus on important metrics.
For example:
CPU
Memory
Disk
Application Errors
Latency
2. Use Meaningful Alarm Names
Bad:
Alarm-123
Good:
Production-EC2-High-CPU
3. Configure Proper Thresholds
Avoid setting unrealistic values.
For example:
CPU > 10%
This may generate unnecessary alerts.
Instead:
CPU > 80%
for 5 minutes
4. Avoid Alert Fatigue
Too many alerts can cause teams to ignore notifications.
Configure alarms only for meaningful issues.
5. Use Multiple Monitoring Layers
A production application should monitor:
Infrastructure
Application
Database
Network
Security
π― Important Interview Questions and Answers
Q1. What is AWS CloudWatch?
Answer:
AWS CloudWatch is a monitoring and observability service that helps monitor AWS resources, applications, metrics, logs, and events. It can also create alarms and trigger automated actions or notifications.
Q2. What is a CloudWatch Metric?
Answer:
A metric is a numerical measurement that represents the performance or behavior of an AWS resource.
Examples include:
CPUUtilization
NetworkIn
NetworkOut
Q3. What is a CloudWatch Alarm?
Answer:
A CloudWatch Alarm monitors a metric and performs an action when the metric crosses a configured threshold.
For example:
CPU > 80%
β
CloudWatch Alarm
β
SNS Notification
Q4. What is a Log Group?
Answer:
A Log Group is a collection of logs from related applications or AWS resources.
For example:
/aws/codebuild/project-name
Multiple log streams can exist inside a Log Group.
Q5. What is the difference between Metrics and Logs?
| Metrics | Logs |
|---|---|
| Numerical data | Detailed event records |
| Used for monitoring | Used for debugging |
| Example: CPU 80% | Example: Application Error |
| Can trigger alarms | Can be searched and analyzed |
Q6. What are the states of a CloudWatch Alarm?
There are three main states:
OK
ALARM
INSUFFICIENT_DATA
Q7. What is Amazon SNS?
Answer:
Amazon Simple Notification Service (SNS) is a messaging service that sends notifications to subscribers using protocols such as email, SMS, HTTP/HTTPS, and AWS services.
Q8. How can CloudWatch send an email alert?
The process is:
CloudWatch Metric
β
CloudWatch Alarm
β
SNS Topic
β
Email Subscription
β
Email Alert
Q9. What is the difference between Default and Custom Metrics?
Default Metrics:
Automatically provided by AWS.
Example:
EC2 CPU Utilization
Custom Metrics:
Metrics manually sent to CloudWatch.
Example:
Application Response Time
Q10. Can CloudWatch monitor memory and disk usage on EC2?
Answer:
These are not typically available as standard EC2 host metrics in the same way as CPU utilization. To collect detailed memory and disk metrics, you generally configure the CloudWatch Agent on the EC2 instance.
π Project Summary
In this project, we created a complete monitoring and alerting system.
Architecture:
EC2 Instance
β
βΌ
CloudWatch Metrics
β
βΌ
CloudWatch Alarm
β
βΌ
Amazon SNS
β
βΌ
π§ Email Notification
What We Learned
β
What AWS CloudWatch is
β
Why monitoring is important
β
CloudWatch Metrics
β
CloudWatch Logs
β
Log Groups and Log Streams
β
CloudWatch Alarms
β
Amazon SNS
β
EC2 CPU Monitoring
β
Creating CPU Threshold Alerts
β
Sending Email Notifications
β
Default vs Custom Metrics
β
CloudWatch Best Practices
β
Real-world monitoring concepts
π Conclusion
AWS CloudWatch is one of the most important services for monitoring AWS infrastructure.
As a DevOps Engineer, deploying an application is only one part of the job. You also need to know whether the application and infrastructure are healthy.
CloudWatch helps answer questions such as:
Is my server healthy? π₯οΈ
Is CPU usage too high? π
Is my application generating errors? β
Is disk space running out? πΎ
Should the DevOps team be alerted? π¨
By combining CloudWatch + CloudWatch Alarms + Amazon SNS, we can build an automated monitoring and alerting system that helps teams detect issues quickly.
Build it β Monitor it β Detect problems β Alert the team β Improve reliability. π
This project is a great beginner step toward understanding AWS Monitoring, Observability, and Production Infrastructure.
π Continue Your Learning Journey
Thank you for taking the time to read this article.
Technology is evolving rapidly, and continuous learning is one of the most valuable investments you can make in your career. Whether you're exploring DevOps, Cloud Computing, Artificial Intelligence, Cybersecurity, Software Development, Data Science, or Career Growth, the resources below can help you deepen your knowledge and stay ahead in the industry.
π Recommended Learning Platforms
π Coursera
Learn from world-renowned universities and industry leaders including Google, IBM, Stanford, Microsoft, Meta, and many more.
β Professional Certificates β Career-focused Learning Paths β AI & Machine Learning Programs β Cloud & DevOps Certifications β Business & Leadership Courses
π https://imp.i384100.net/k0KvbV
π» Udemy
One of the largest online learning platforms with practical, hands-on courses covering:
β DevOps & Kubernetes β Docker & Cloud Computing β AWS, Azure & GCP β Programming & Development β Cybersecurity & Ethical Hacking
π https://trk.udemy.com/MAL2MY
π DataCamp
A great platform for anyone interested in:
β Python Programming β SQL & Databases β Data Analytics β Machine Learning β Artificial Intelligence
Interactive learning paths and hands-on projects make it ideal for beginners and professionals alike.
π https://datacamp.pxf.io/nX4kER
π edX
Access high-quality courses and certifications from leading institutions such as:
β Harvard University β MIT β Berkeley β Microsoft
Perfect for learners seeking university-level education online.
π https://edx.sjv.io/POvVeN
π¨ Domestika
Enhance your creative skills with courses on:
β Graphic Design β Video Editing β Animation β Digital Marketing β Content Creation
π https://domestika.sjv.io/dynKAW
π οΈ Recommended Tools & Resources
π₯ AppSumo
Discover exclusive lifetime deals on:
β AI Tools β Productivity Software β Developer Utilities β Marketing Platforms β Business Applications
A must-have resource for developers, creators, freelancers, and entrepreneurs looking to save money while accessing premium tools.
π https://appsumo.8odi.net/L04a33
π Shopify
Looking to start an online business or launch an eCommerce store?
Shopify provides everything you need to build, manage, and scale an online business.
β Online Store Builder β Payment Integration β Inventory Management β Marketing Tools
π https://shopify.pxf.io/Vxv09k
π WordPress, WooCommerce & Jetpack
Create professional websites, blogs, and online stores with one of the most trusted web ecosystems in the world.
Ideal for:
β Personal Blogs β Portfolio Websites β Business Websites β eCommerce Stores
π https://automattic.pxf.io/Z6vR5W
π Language Learning Resources
π£οΈ Preply
Learn English and other languages through personalized one-on-one tutoring sessions with experts from around the world.
π https://preply.sjv.io/o4gBDY
π British Council English Online
Improve your professional communication skills and English fluency through structured learning programs.
π https://englishonline.sjv.io/9VOGa4
π§ Rosetta Stone
One of the most recognized language-learning platforms for immersive language acquisition.
π https://aff.rosettastone.com/X4OyqG
π§ͺ Science & Educational Resources
π¬ MEL Science
Interactive science kits and educational experiences designed to make STEM learning engaging and practical.
π https://imp.i328067.net/bk2beg
π Carson Dellosa Education
Educational materials and learning resources for students, teachers, and lifelong learners.
π https://carsondellosaeducation.sjv.io/E0JbjW
β€οΈ Support My Work
Creating detailed technical content, tutorials, guides, and learning resources takes significant time and effort.
If you find my articles helpful and would like to support my work, you can do so through the following platforms:
β Become a GitHub Sponsor
Support my open-source contributions, technical content, and community projects.
π https://github.com/sponsors/hritikranjan1
β Buy Me a Chai
Enjoying my content? Consider buying me a chai and supporting future tutorials, guides, and educational resources.
π https://www.chai4.me/hritikranjan
π¨βπ» Connect With Me
Hritik Ranjan
π‘ AI Enthusiast βοΈ DevOps Learner π Cybersecurity Advocate π» Software Developer
Connect & Follow
π GitHub: https://github.com/hritikranjan1
π LinkedIn: https://linkedin.com/in/hritikranjan1
π’ Found This Article Helpful?
If this article added value to your learning journey:
β Share it with your network β Bookmark it for future reference β Follow for more DevOps, AI, Cloud, Cybersecurity, and Software Engineering content
Thank you for reading and being part of this learning journey.
Keep Learning. Keep Building. Keep Growing. π






