0
0
AWScloud~30 mins

CloudWatch metrics in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic CloudWatch Metrics Setup
📖 Scenario: You are managing a simple web application hosted on AWS. You want to monitor the CPU usage of your application servers to ensure they are running smoothly and to detect any performance issues early.
🎯 Goal: Create a CloudWatch metric setup that tracks CPU utilization for your application servers. You will define the metric data, configure a threshold for high CPU usage, apply the monitoring logic, and complete the CloudWatch alarm configuration.
📋 What You'll Learn
Create a CloudWatch metric data dictionary with exact keys and values
Add a threshold variable for CPU utilization
Write a function to check if CPU usage exceeds the threshold
Complete the CloudWatch alarm configuration with the correct metric and threshold
💡 Why This Matters
🌍 Real World
Monitoring server CPU usage helps keep applications running smoothly and prevents downtime by alerting when resources are overused.
💼 Career
Cloud engineers and DevOps professionals use CloudWatch metrics and alarms to maintain healthy cloud infrastructure and respond quickly to issues.
Progress0 / 4 steps
1
Create CloudWatch metric data dictionary
Create a dictionary called cpu_metric with these exact entries: 'Namespace': 'AWS/EC2', 'MetricName': 'CPUUtilization', 'Dimensions': [{'Name': 'InstanceId', 'Value': 'i-1234567890abcdef0'}], and 'Unit': 'Percent'.
AWS
Need a hint?

Think of cpu_metric as a label that describes what you want to measure in AWS CloudWatch.

2
Add CPU utilization threshold
Create a variable called cpu_threshold and set it to the integer 80 to represent 80% CPU usage as the alert threshold.
AWS
Need a hint?

This threshold will help you decide when CPU usage is too high.

3
Write function to check CPU usage against threshold
Write a function called is_cpu_high that takes a parameter cpu_usage and returns True if cpu_usage is greater than cpu_threshold, otherwise returns False.
AWS
Need a hint?

This function helps you decide if the CPU usage is above the limit you set.

4
Complete CloudWatch alarm configuration
Create a dictionary called cpu_alarm with these exact entries: 'AlarmName': 'HighCPUUsage', 'MetricName': cpu_metric['MetricName'], 'Namespace': cpu_metric['Namespace'], 'Dimensions': cpu_metric['Dimensions'], 'Threshold': cpu_threshold, 'ComparisonOperator': 'GreaterThanThreshold', and 'EvaluationPeriods': 1.
AWS
Need a hint?

This dictionary represents the alarm that will notify you when CPU usage is too high.