Complete the code to start monitoring CPU usage with AWS CloudWatch.
aws cloudwatch [1] --metric-name CPUUtilization --namespace AWS/EC2The get-metric-statistics command retrieves CPU usage data from CloudWatch.
Complete the code to create an alarm for high CPU usage.
aws cloudwatch put-metric-alarm --alarm-name HighCPU --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold [1] --comparison-operator GreaterThanThreshold --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:123456789012:NotifyMe
The threshold of 80 means the alarm triggers when CPU usage is above 80%.
Fix the error in the command to list all CloudWatch alarms.
aws cloudwatch [1]-alarmsThe correct command is describe-alarms to list alarms in CloudWatch.
Fill both blanks to create a CloudWatch alarm that triggers when disk space is low.
aws cloudwatch put-metric-alarm --alarm-name LowDiskSpace --metric-name [1] --namespace AWS/EC2 --statistic Average --period 300 --threshold [2] --comparison-operator LessThanThreshold --evaluation-periods 1 --alarm-actions arn:aws:sns:us-east-1:123456789012:NotifyMe
The metric DiskSpaceUtilization tracks disk usage, and a threshold of 10 means alarm triggers when disk space is below 10%.
Fill all three blanks to create a CloudWatch dashboard widget showing average CPU usage.
aws cloudwatch put-dashboard --dashboard-name MyDashboard --dashboard-body '{"widgets": [{"type": "metric", "x": 0, "y": 0, "width": 6, "height": 6, "properties": {"metrics": [["[1]", "[2]", "[3]"]], "period": 300, "stat": "Average"}}]}'
The dashboard widget needs the namespace AWS/EC2, metric name CPUUtilization, and dimension InstanceId to show CPU usage per instance.