Bird
Raised Fist0
AWScloud~10 mins

CloudWatch alarms in AWS - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the metric name for the CloudWatch alarm.

AWS
MetricName: "[1]"
Drag options to blanks, or click blank then click option'
AStatusCheckFailed
BDiskReadOps
CNetworkIn
DCPUUtilization
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a metric that does not exist or is unrelated to CPU usage.
2fill in blank
medium

Complete the code to set the comparison operator for the alarm.

AWS
ComparisonOperator: "[1]"
Drag options to blanks, or click blank then click option'
AEqualToThreshold
BLessThanThreshold
CGreaterThanThreshold
DNotEqualToThreshold
Attempts:
3 left
💡 Hint
Common Mistakes
Using LessThanThreshold when you want to detect high values.
3fill in blank
hard

Fix the error in the alarm configuration by completing the missing statistic field.

AWS
Statistic: "[1]"
Drag options to blanks, or click blank then click option'
AAverage
BMaximum
CMinimum
DSum
Attempts:
3 left
💡 Hint
Common Mistakes
Using Sum when you want the average value.
4fill in blank
hard

Fill both blanks to set the alarm threshold and evaluation periods.

AWS
Threshold: [1], EvaluationPeriods: [2]
Drag options to blanks, or click blank then click option'
A80
B3
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing threshold with evaluation periods values.
5fill in blank
hard

Fill all three blanks to complete the alarm action configuration.

AWS
AlarmActions: ["[1]"], OKActions: ["[2]"], InsufficientDataActions: ["[3]"]
Drag options to blanks, or click blank then click option'
Aarn:aws:sns:us-east-1:123456789012:NotifyMe
Barn:aws:sns:us-east-1:123456789012:ClearNotify
Carn:aws:sns:us-east-1:123456789012:DataMissingNotify
Darn:aws:sns:us-east-1:123456789012:OtherTopic
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the ARNs for different alarm states.

Practice

(1/5)
1. What is the primary purpose of an AWS CloudWatch alarm?
easy
A. To store large amounts of log data
B. To monitor a specific metric and notify when it crosses a threshold
C. To create virtual servers in the cloud
D. To manage user permissions and roles

Solution

  1. Step 1: Understand CloudWatch alarm function

    CloudWatch alarms watch metrics like CPU usage or disk space and alert you when values cross set limits.
  2. Step 2: Identify the correct purpose

    Only To monitor a specific metric and notify when it crosses a threshold describes monitoring a metric and notifying on threshold crossing, which is the alarm's job.
  3. Final Answer:

    To monitor a specific metric and notify when it crosses a threshold -> Option B
  4. Quick Check:

    Alarm = Monitor + Notify [OK]
Hint: Alarms watch metrics and alert on changes [OK]
Common Mistakes:
  • Confusing alarms with log storage
  • Thinking alarms create servers
  • Mixing alarms with user management
2. Which of the following is the correct way to specify a CloudWatch alarm threshold for CPU utilization above 80%?
easy
A. "Threshold": "<=80"
B. "Threshold": 80, "ComparisonOperator": "LessThanThreshold"
C. "Threshold": 80, "ComparisonOperator": "LessThanOrEqualToThreshold"
D. "Threshold": 80, "ComparisonOperator": "GreaterThanThreshold"

Solution

  1. Step 1: Understand threshold syntax

    CloudWatch alarms use a numeric Threshold value and a separate ComparisonOperator like GreaterThanThreshold, LessThanThreshold.
  2. Step 2: Choose operator for above 80%

    To alert when CPU is above 80%, use "Threshold": 80, "ComparisonOperator": "GreaterThanThreshold".
  3. Final Answer:

    "Threshold": 80, "ComparisonOperator": "GreaterThanThreshold" -> Option D
  4. Quick Check:

    Above 80% = GreaterThanThreshold(80) [OK]
Hint: Use GreaterThanThreshold for above threshold [OK]
Common Mistakes:
  • Using < instead of > for above threshold
  • Using = which triggers only at exact value
  • Confusing <= with above threshold
3. Given this CloudWatch alarm configuration snippet:
{"MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "Threshold": 70, "ComparisonOperator": "GreaterThanThreshold", "EvaluationPeriods": 3}

What happens if CPU utilization is 75% for 2 consecutive periods and then 65% for the third period?
medium
A. The alarm does not trigger because CPU was not above 70% for all 3 periods
B. The alarm triggers only if CPU is above 70% for 4 periods
C. The alarm triggers immediately when CPU hits 75% the first time
D. The alarm triggers because CPU was above 70% twice

Solution

  1. Step 1: Understand EvaluationPeriods meaning

    The alarm triggers only if the metric breaches the threshold for the specified number of consecutive periods (3 here).
  2. Step 2: Analyze given CPU values

    CPU was above 70% for 2 periods, then dropped below on the 3rd, so the alarm does not trigger.
  3. Final Answer:

    The alarm does not trigger because CPU was not above 70% for all 3 periods -> Option A
  4. Quick Check:

    3 periods breach needed, only 2 met [OK]
Hint: Alarm needs all evaluation periods breached [OK]
Common Mistakes:
  • Thinking alarm triggers after any single breach
  • Ignoring EvaluationPeriods count
  • Assuming alarm triggers immediately
4. You created a CloudWatch alarm but it never enters ALARM state even when the metric crosses the threshold. What is a likely cause?
medium
A. The alarm's EvaluationPeriods is set higher than the number of metric data points
B. The alarm threshold is set too low
C. The alarm is configured to notify but not to monitor metrics
D. The SNS topic ARN configured in alarm actions is invalid

Solution

  1. Step 1: Check EvaluationPeriods vs data points

    If EvaluationPeriods is more than available metric data points, alarm cannot evaluate properly.
  2. Step 2: Confirm impact on alarm state

    Without enough data points, alarm never sees enough breaches to enter ALARM state.
  3. Final Answer:

    The alarm's EvaluationPeriods is set higher than the number of metric data points -> Option A
  4. Quick Check:

    EvaluationPeriods > data points = no alarm [OK]
Hint: Ensure enough data points for EvaluationPeriods [OK]
Common Mistakes:
  • Assuming threshold too low prevents alarm
  • Confusing notification with monitoring
  • Thinking invalid SNS prevents alarm state
5. You want to create a CloudWatch alarm that triggers an auto-scaling action when average CPU utilization exceeds 60% for 5 minutes, but only if this happens during business hours (9 AM to 5 PM). Which approach best achieves this?
hard
A. Create a CloudWatch alarm with threshold 60% and EvaluationPeriods 1, then use EventBridge to trigger scaling only during business hours
B. Set the alarm threshold to 60% and EvaluationPeriods to 5, and configure the alarm to be active only during business hours
C. Create a CloudWatch alarm with threshold 60% and EvaluationPeriods 5, then use a Lambda function triggered by the alarm to check time and trigger scaling
D. Set the alarm threshold to 60% and EvaluationPeriods 5, and configure auto-scaling to ignore alarms outside business hours

Solution

  1. Step 1: Understand alarm and time condition needs

    CloudWatch alarms alone cannot restrict triggering by time; external logic is needed.
  2. Step 2: Evaluate options for time-based control

    Using a Lambda triggered by the alarm to check current time and decide on scaling is flexible and precise.
  3. Step 3: Assess other options

    EventBridge can schedule events but not filter alarm triggers by time; auto-scaling ignores alarms is not a feature.
  4. Final Answer:

    Create a CloudWatch alarm with threshold 60% and EvaluationPeriods 5, then use a Lambda function triggered by the alarm to check time and trigger scaling -> Option C
  5. Quick Check:

    Alarm + Lambda time check = controlled scaling [OK]
Hint: Use Lambda to add time logic after alarm triggers [OK]
Common Mistakes:
  • Expecting alarm to handle time filtering alone
  • Assuming auto-scaling ignores alarms by time
  • Using EventBridge without alarm integration
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard