0
0
GCPcloud~20 mins

Log-based metrics in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Log-based Metrics Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Understanding Log-based Metric Behavior

You create a log-based metric in Google Cloud Logging to count the number of error logs containing the word "Timeout". After deploying, you notice the metric value remains zero even though errors occur.

What is the most likely reason?

AThe filter for the log-based metric does not include the correct severity level or text match for "Timeout".
BThe metric is delayed by 24 hours before showing any data.
CLog-based metrics only count logs from Cloud Storage buckets, not from Compute Engine.
DThe metric requires manual data import from logs before it starts counting.
Attempts:
2 left
💡 Hint

Check how the filter matches logs for the metric.

Configuration
intermediate
2:00remaining
Creating a Counter Log-based Metric Filter

You want to create a counter log-based metric that counts all HTTP 500 errors logged by your application in Cloud Logging.

Which filter correctly matches these logs?

Aresource.type="gce_instance" AND severity>=ERROR AND jsonPayload.status=500
Bresource.type="gce_instance" AND severity="ERROR" AND jsonPayload.status=500
Cresource.type="http_load_balancer" AND severity="ERROR" AND jsonPayload.status_code=500
Dresource.type="http_load_balancer" AND severity="ERROR" AND jsonPayload.status=500
Attempts:
2 left
💡 Hint

Check the resource type and field names used in your logs.

Architecture
advanced
2:30remaining
Designing Log-based Metrics for Cost Efficiency

Your team wants to monitor specific error patterns in logs but minimize costs from exporting large volumes of logs. Which approach best balances detailed monitoring and cost control?

ADisable log-based metrics and rely on manual log scanning to reduce costs.
BExport all logs to BigQuery and create metrics from there to avoid using log-based metrics.
CCreate a single broad log-based metric counting all errors and export all logs to Cloud Storage.
DCreate multiple detailed log-based metrics with narrow filters and export only metric data to BigQuery.
Attempts:
2 left
💡 Hint

Think about how log-based metrics and exports affect cost.

security
advanced
2:00remaining
Securing Access to Log-based Metrics

You want to restrict who can create or modify log-based metrics in your Google Cloud project to prevent unauthorized changes.

Which IAM role should you assign to users who need to manage log-based metrics?

Aroles/monitoring.metricWriter
Broles/logging.admin
Croles/logging.viewer
Droles/owner
Attempts:
2 left
💡 Hint

Check which role allows managing logging configurations.

Best Practice
expert
3:00remaining
Optimizing Log-based Metric Filters for Performance

You have a log-based metric with a complex filter that includes multiple OR conditions and regex matches. You notice the metric updates slowly and sometimes misses logs.

Which change will most improve performance and accuracy?

AIncrease the metric's sampling rate to capture more logs.
BAdd more regex patterns to cover all possible log variations in one filter.
CSimplify the filter by replacing OR conditions with multiple separate metrics each with simpler filters.
DUse a single broad filter without conditions to capture all logs and filter later in monitoring tools.
Attempts:
2 left
💡 Hint

Think about how complex filters affect log processing.