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?
Check how the filter matches logs for the metric.
Log-based metrics count logs matching their filter immediately. If the filter is incorrect or too narrow, no logs match, so the metric stays zero.
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?
Check the resource type and field names used in your logs.
The filter must match the resource type where the logs come from and the exact field name for the HTTP status code. Typically, Compute Engine instances use resource.type="gce_instance" and the status code field is jsonPayload.status.
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?
Think about how log-based metrics and exports affect cost.
Log-based metrics count logs internally and export only metric data, which is cheaper than exporting all logs. Using narrow filters reduces metric data volume. Exporting all logs is costly.
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?
Check which role allows managing logging configurations.
The roles/logging.admin role allows creating and modifying log-based metrics. roles/logging.viewer only allows viewing logs. roles/monitoring.metricWriter is for monitoring metrics but not logging configs. roles/owner is too broad.
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?
Think about how complex filters affect log processing.
Complex filters with many ORs and regexes slow down log processing and can cause missed matches. Splitting into multiple simpler metrics improves performance and accuracy.