
Monitoring AWS Resources with Amazon CloudWatch
Hands-on notes on CloudWatch metrics, dimensions, dashboards, alarms, agents, and automated actions.
I recently completed the AWS SimuLearn: Resource Monitoring lab and learned how Amazon CloudWatch can monitor AWS resources, visualize metrics, detect problems, and trigger automated actions.
The main workflow I learned was:
1
2
3
4
5
6
7
8
9
10
11
AWS Resource
↓
Metrics
↓
CloudWatch
↓
Dashboard
↓
Alarm
↓
Notification / Automated ActionMetrics, Namespaces, and Dimensions
A metric is a value measured over time, such as CPU usage, network traffic, or memory usage.
CloudWatch organizes metrics into namespaces:
1
2
3
AWS/EC2
AWS/Lambda
PowerPlantMetricsA dimension identifies what a metric belongs to.
1
2
3
4
5
Metric: CPU_USAGE_IDLE
Dimensions:
InstanceId = i-123
InstanceType = t3.microMy mental model is:
1
2
Metric = What am I measuring?
Dimension = Which resource does it belong to?EC2 Monitoring
Amazon EC2 automatically publishes several infrastructure metrics to CloudWatch.
1
2
3
4
5
6
Basic Monitoring
→ 5-minute metric periods
Detailed Monitoring
→ 1-minute metric periods
→ faster visibility and alarmsFor operating-system-level metrics such as memory usage, the CloudWatch Agent can collect data from inside the EC2 instance.
1
2
3
4
5
6
7
EC2 OS
↓
CloudWatch Agent
↓
Custom Metrics
↓
CloudWatchPublishing Custom Metrics
An application or CloudWatch Agent can also publish custom metrics through the CloudWatch API.
For an EC2 instance to push metrics, I learned that it generally needs:
1
2
3
4
5
CloudWatch Agent / Application
+
IAM permission
+
Network path to CloudWatchFor example, the IAM role may allow:
1
cloudwatch:PutMetricDataUsing an IAM role is better than storing long-term access keys directly on the EC2 instance.
Dashboards
CloudWatch Dashboards combine multiple graphs and monitoring widgets into one place.
1
2
3
4
5
6
Power Plant Dashboard
├── CPU Server 1
├── CPU Server 2
├── CPU Server 3
├── Memory Usage
└── Alarm StatusA widget can also keep its own time range, such as Last 3 hours, instead of following the dashboard's global time range.
Alarms and Automated Actions
A CloudWatch Alarm evaluates a metric against a condition.
For example:
1
2
3
4
5
mem_used > 300 MB
↓
CloudWatch Alarm
↓
ALARMThe alarm can then trigger an action:
1
2
3
4
5
6
7
8
CloudWatch Alarm
↓
┌─────┴─────┐
↓ ↓
SNS EC2 Action
↓ ↓
Notify Reboot
Engineer InstanceThis means engineers do not need to watch the dashboard continuously. CloudWatch can detect the problem and respond automatically.
My Main Takeaway
The simplest mental model I took away from this lab is:
1
2
3
4
5
Metrics = What is happening?
Dimensions = Which resource?
Dashboard = Show everything together
Alarm = Detect a problem
Action = What should happen next?CloudWatch is more than a graphing tool. It provides a centralized way to collect, visualize, detect, alert, and respond to changes in AWS resources and applications.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article