📖 Scenario: You are managing a small web application running on Google Cloud Platform (GCP). You want to keep track of your application's health by monitoring CPU usage and uptime. This will help you quickly spot problems and keep your app running smoothly.
🎯 Goal: Build a simple Cloud Monitoring setup using Google Cloud SDK commands to create a monitored resource, configure an uptime check, and list the configured uptime checks.
📋 What You'll Learn
Use the gcloud command-line tool
Create a monitored resource descriptor for a virtual machine instance
Configure an uptime check for the web application
List all uptime checks to verify the setup
💡 Why This Matters
🌍 Real World
Cloud Monitoring helps keep applications healthy by automatically checking if they are up and running. This project shows how to set up basic uptime checks for your services.
💼 Career
Knowing how to configure and manage uptime checks is a key skill for cloud engineers and DevOps professionals to ensure system reliability and quick incident response.
Progress0 / 4 steps
1
Create a monitored resource descriptor
Use the gcloud monitoring resource-descriptors list command to list available monitored resource types. Then create a monitored resource descriptor for a virtual machine instance named my-instance in zone us-central1-a.
GCP
Hint
First, list resource descriptors with gcloud monitoring resource-descriptors list. Then define a dictionary with type as gce_instance and labels for instance_id and zone.
2
Configure an uptime check
Create a variable called uptime_check_config that defines an uptime check for the URL http://my-instance.example.com with a check interval of 60 seconds and timeout of 10 seconds.
GCP
Hint
Define uptime_check_config as a dictionary with keys display_name, http_check, resource, period, and timeout. Use the monitored resource from Step 1.
3
Create the uptime check using gcloud
Use the gcloud monitoring uptime-checks create http command to create an uptime check for the URL http://my-instance.example.com with a check interval of 60 seconds and timeout of 10 seconds.
GCP
Hint
Use the gcloud monitoring uptime-checks create http command with flags --display-name, --host, --path, --period, and --timeout.
4
List all uptime checks
Use the gcloud monitoring uptime-checks list command to display all configured uptime checks and verify that your uptime check named My Instance Uptime Check is listed.
GCP
Hint
Run gcloud monitoring uptime-checks list to see all uptime checks. Look for the name My Instance Uptime Check in the output.
Practice
(1/5)
1. What is the main purpose of Cloud Monitoring in Google Cloud Platform?
easy
A. To watch and track the health and performance of cloud resources
B. To create virtual machines automatically
C. To store large amounts of data securely
D. To manage user permissions and roles
Solution
Step 1: Understand Cloud Monitoring's role
Cloud Monitoring is designed to observe and report on the status and performance of cloud resources.
Step 2: Compare options with this role
Options B, C, and D describe other services like Compute Engine, Cloud Storage, and IAM, not monitoring.
Final Answer:
To watch and track the health and performance of cloud resources -> Option A
Quick Check:
Cloud Monitoring = watch cloud health [OK]
Hint: Monitoring means watching resource health and performance [OK]
The notification channel ID must be a valid existing channel; '1234567890' is likely a placeholder or invalid.
Step 2: Verify other flags
Flags like condition filter and threshold value are syntactically correct; aggregation is optional.
Final Answer:
Notification channel ID is invalid or missing -> Option B
Quick Check:
Invalid notification channel causes failure [OK]
Hint: Check notification channel IDs exist before using [OK]
Common Mistakes:
Assuming aggregation is always required
Misformatting condition filter
Using wrong data type for threshold
5. You want to create a dashboard that shows CPU utilization and memory usage for your Compute Engine instances. Which steps should you follow?
hard
A. Use Cloud Console to create a dashboard, add widgets for CPU and memory metrics, then save
B. Run gcloud commands to create a dashboard and add metrics in one command
C. Create alert policies for CPU and memory, then dashboards are created automatically
D. Use Cloud Storage to upload a JSON file with dashboard configuration
Solution
Step 1: Understand dashboard creation process
Dashboards are created in Cloud Console by adding widgets for desired metrics.
Step 2: Evaluate options for dashboard creation
Use Cloud Console to create a dashboard, add widgets for CPU and memory metrics, then save describes the correct manual process. Run gcloud commands to create a dashboard and add metrics in one command is incorrect as gcloud does not support full dashboard creation in one command. Create alert policies for CPU and memory, then dashboards are created automatically confuses alerts with dashboards. Use Cloud Storage to upload a JSON file with dashboard configuration misuses Cloud Storage.
Final Answer:
Use Cloud Console to create a dashboard, add widgets for CPU and memory metrics, then save -> Option A
Quick Check:
Dashboards made via Console with widgets [OK]
Hint: Create dashboards in Console by adding metric widgets [OK]
Common Mistakes:
Thinking gcloud can create dashboards fully
Confusing alert policies with dashboards
Uploading dashboard configs to Cloud Storage
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.