0
0
GCPcloud~10 mins

Why observability matters in GCP - Test Your Understanding

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

Complete the code to create a Stackdriver Monitoring client in GCP.

GCP
from google.cloud import monitoring_v3
client = monitoring_v3.[1]()
Drag options to blanks, or click blank then click option'
AStorageClient
BLoggingServiceV2Client
CMetricServiceClient
DComputeClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using LoggingServiceV2Client instead of MetricServiceClient
Using StorageClient which is unrelated
2fill in blank
medium

Complete the code to define a metric descriptor type for a custom metric.

GCP
metric_descriptor.type = "custom.googleapis.com/[1]"
Drag options to blanks, or click blank then click option'
Anetwork_traffic
Bmemory
Cdisk_io
Dcpu_usage
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'memory' without context
Using unsupported metric names
3fill in blank
hard

Fix the error in the code to write a time series data point for a custom metric.

GCP
series.metric.type = "custom.googleapis.com/cpu_usage"
series.resource.type = "[1]"
Drag options to blanks, or click blank then click option'
Aglobal
Bgce_instance
Ck8s_container
Dcloud_function
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'global' which is not specific
Using 'cloud_function' which is for serverless functions
4fill in blank
hard

Fill both blanks to create a filter string to query CPU usage metrics for a specific instance.

GCP
filter = 'metric.type="custom.googleapis.com/cpu_usage" AND resource.labels.instance_id=[1] AND resource.type=[2]'
Drag options to blanks, or click blank then click option'
A"1234567890123456789"
B"gce_instance"
C"cloud_run_revision"
D"my-instance-id"
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric IDs without quotes
Using wrong resource types like cloud_run_revision
5fill in blank
hard

Fill all three blanks to create a monitoring alert policy condition for high CPU usage.

GCP
condition = monitoring_v3.AlertPolicy.Condition(
    display_name="High CPU Usage",
    condition_threshold=monitoring_v3.AlertPolicy.Condition.MetricThreshold(
        filter="metric.type=\"custom.googleapis.com/cpu_usage\" AND resource.type=\"[1]\"",
        comparison=monitoring_v3.AlertPolicy.Condition.MetricThreshold.ComparisonType.[2],
        threshold_value=[3],
        duration=duration_pb2.Duration(seconds=300),
        aggregations=[]
    )
)
Drag options to blanks, or click blank then click option'
Agce_instance
BGREATER_THAN
C80.0
Dcloud_function
Attempts:
3 left
💡 Hint
Common Mistakes
Using cloud_function instead of gce_instance
Using wrong comparison operators
Setting threshold too low or high