0
0
AWScloud~30 mins

CloudWatch alarms in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Create a CloudWatch Alarm for CPU Utilization
📖 Scenario: You are managing a cloud server and want to monitor its CPU usage. If the CPU usage goes above a certain limit, you want to get notified automatically.
🎯 Goal: Build a CloudWatch alarm that watches the CPU utilization of an EC2 instance and triggers when the usage is above 70% for 5 minutes.
📋 What You'll Learn
Create a variable with the EC2 instance ID
Set a threshold value for CPU utilization
Define a CloudWatch alarm using the instance ID and threshold
Configure the alarm to trigger after 5 minutes of high CPU usage
💡 Why This Matters
🌍 Real World
CloudWatch alarms are used by cloud engineers to monitor server health and get alerts before problems affect users.
💼 Career
Knowing how to configure CloudWatch alarms is essential for roles like Cloud Engineer, DevOps Engineer, and Site Reliability Engineer.
Progress0 / 4 steps
1
Set the EC2 instance ID
Create a variable called instance_id and set it to the string "i-0abcd1234efgh5678" which represents your EC2 instance ID.
AWS
Need a hint?

The EC2 instance ID is a string. Use quotes around it.

2
Set the CPU utilization threshold
Create a variable called cpu_threshold and set it to the number 70 which will be the CPU usage percentage limit for the alarm.
AWS
Need a hint?

Threshold is a number without quotes.

3
Define the CloudWatch alarm configuration
Create a dictionary called cloudwatch_alarm with these exact keys and values: AlarmName set to "HighCPUAlarm", MetricName set to "CPUUtilization", Namespace set to "AWS/EC2", Statistic set to "Average", Period set to 60, EvaluationPeriods set to 5, Threshold set to the variable cpu_threshold, ComparisonOperator set to "GreaterThanThreshold", and Dimensions set to a list with one dictionary containing Name as "InstanceId" and Value as the variable instance_id.
AWS
Need a hint?

Use a dictionary with the exact keys and values. Use the variables for threshold and instance ID.

4
Add the alarm action configuration
Add a key called AlarmActions to the cloudwatch_alarm dictionary and set its value to a list containing the string "arn:aws:sns:us-east-1:123456789012:NotifyMe" which represents the SNS topic ARN to notify when the alarm triggers.
AWS
Need a hint?

AlarmActions is a list with one string ARN.