📖 Scenario: You are managing a Google Cloud Platform project and want to be notified when your virtual machine CPU usage is too high. To do this, you will create an alerting policy that watches CPU utilization and sends an email notification if it goes above a certain limit.
🎯 Goal: Build a simple alerting policy in Google Cloud Monitoring that triggers when CPU usage exceeds 80% for a virtual machine instance.
📋 What You'll Learn
Create a metric threshold condition for CPU utilization
Set the threshold value to 80%
Configure the alerting policy with a notification channel
Name the alerting policy clearly
💡 Why This Matters
🌍 Real World
Alerting policies help cloud administrators get notified about important issues like high CPU usage, so they can act quickly to maintain system health.
💼 Career
Understanding how to create and configure alerting policies is essential for cloud engineers and site reliability engineers to ensure system reliability and uptime.
Progress0 / 4 steps
1
Define the CPU Utilization Metric Condition
Create a dictionary called cpu_condition with these exact keys and values: displayName set to "VM CPU Utilization", conditionThreshold as a nested dictionary with filter set to "metric.type=\"compute.googleapis.com/instance/cpu/utilization\"", comparison set to "COMPARISON_GT", thresholdValue set to 0.8, and duration set to "60s".
GCP
Hint
Use a dictionary with nested dictionaries to define the metric condition.
2
Create the Notification Channel Configuration
Create a dictionary called notification_channel with the key type set to "email" and the key labels set to a dictionary with email_address set to "alert@example.com".
GCP
Hint
Notification channels use a dictionary with type and labels keys.
3
Build the Alerting Policy Dictionary
Create a dictionary called alert_policy with the key displayName set to "High CPU Usage Alert", the key conditions set to a list containing the cpu_condition dictionary, and the key notificationChannels set to a list containing the string "email-alert-channel".
GCP
Hint
Use a dictionary with keys displayName, conditions, and notificationChannels.
4
Add Documentation and Finalize the Alerting Policy
Add a key documentation to the alert_policy dictionary with a nested dictionary containing content set to "Alert when VM CPU usage exceeds 80% for 1 minute." and mimeType set to "text/markdown".
GCP
Hint
Documentation helps explain the alert policy purpose.
Practice
(1/5)
1. What is the main purpose of an alerting policy in Google Cloud Monitoring?
easy
A. To watch cloud metrics and notify when something needs attention
B. To deploy virtual machines automatically
C. To store data backups securely
D. To manage user access permissions
Solution
Step 1: Understand the role of alerting policies
An alerting policy monitors cloud metrics continuously to detect issues.
Step 2: Identify the main function
When a condition is met, it sends notifications to inform the team.
Final Answer:
To watch cloud metrics and notify when something needs attention -> Option A
Quick Check:
Alerting policy = notify on metric issues [OK]
Hint: Alerting policies notify on metric changes [OK]
Common Mistakes:
Confusing alerting with deployment
Thinking alerting manages backups
Mixing alerting with access control
2. Which of the following is the correct way to specify a notification channel in a Google Cloud alerting policy configuration?
easy
A. "channels": "my-project/notification/12345"
B. "notifyChannel": "12345"
C. "notification": "channel-12345"
D. "notificationChannels": ["projects/my-project/notificationChannels/12345"]
Solution
Step 1: Recall notification channel format
Google Cloud expects notification channels as full resource names in an array.
Step 2: Match correct syntax
"notificationChannels": ["projects/my-project/notificationChannels/12345"] uses the correct JSON key and full resource path format.
Final Answer:
"notificationChannels": ["projects/my-project/notificationChannels/12345"] -> Option D
Quick Check:
Notification channels use full resource names in array [OK]
Hint: Use full resource names in an array for notificationChannels [OK]
Common Mistakes:
Using wrong key names like notifyChannel
Providing notification channel as a string, not array
B. CPU utilization is greater than 80% for 5 minutes
C. CPU utilization is exactly 80% at any time
D. CPU utilization is greater than 80% for 30 seconds
Solution
Step 1: Interpret the condition filter and comparison
The filter targets CPU utilization metric, and comparison is greater than 0.8 (80%).
Step 2: Understand the duration
The duration is 300 seconds, meaning the condition must hold for 5 minutes continuously.
Final Answer:
CPU utilization is greater than 80% for 5 minutes -> Option B
Quick Check:
Threshold > 0.8 for 300s = alert [OK]
Hint: Check comparison and duration for alert trigger [OK]
Common Mistakes:
Confusing greater than with less than
Ignoring duration requirement
Assuming exact equality triggers alert
4. You created an alerting policy but no notifications are sent when the condition is met. What is the most likely cause?
medium
A. Notification channels are not configured or linked properly
B. The metric filter is too broad
C. The alerting policy is disabled by default
D. The project has no billing account
Solution
Step 1: Check notification channel setup
If no notifications arrive, the most common cause is missing or incorrect notification channels.
Step 2: Verify alerting policy status and billing
Alerting policies are enabled by default and billing issues usually don't block notifications.
Final Answer:
Notification channels are not configured or linked properly -> Option A
Quick Check:
No notifications usually mean missing channels [OK]
Hint: Verify notification channels linked to policy [OK]
Common Mistakes:
Assuming alerting policies are disabled by default
Blaming billing for notification failure
Ignoring notification channel configuration
5. You want to create an alerting policy that notifies your team only if CPU usage is above 70% for 10 minutes, but only during business hours (9 AM to 5 PM). Which approach best achieves this?
hard
A. Set the alert threshold to 70% and rely on team to ignore alerts outside business hours
B. Create an alerting policy without conditions and manually check CPU usage during business hours
C. Use an alerting policy with a condition on CPU usage and add a time window using an uptime check or schedule-based notification channel
D. Configure the alerting policy to notify continuously regardless of time
Solution
Step 1: Define CPU usage condition with duration
Set condition threshold to >70% CPU usage sustained for 10 minutes.
Step 2: Limit notifications to business hours
Use scheduling features like uptime checks or notification channel schedules to restrict alerts to 9 AM-5 PM.
Final Answer:
Use an alerting policy with a condition on CPU usage and add a time window using an uptime check or schedule-based notification channel -> Option C
Quick Check:
Combine metric condition + time window for precise alerts [OK]
Hint: Combine metric condition with time-based notification [OK]
Common Mistakes:
Ignoring time restrictions in alerting policy
Relying on manual checks instead of automation
Not setting duration for CPU usage condition
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.