A site reliability engineer (SRE) manages a web microservice deployed on Cloud Run. The team needs to track specific application error events appearing in the execution logs (`jsonPayload.errorCode = "ERR_DATABASE_TIMEOUT"`) and trigger automated notifications to a Webhook endpoint and a Pub/Sub topic whenever these errors exceed 10 occurrences within a 5-minute period. Which TWO steps should the engineer perform to implement this observability requirement in Google Cloud? (Select TWO.)
- Create a counter log-based metric in Cloud Logging using a log filter matching the specific error code.Cevap
- Create a Cloud Monitoring alerting policy based on the log-based metric threshold and configure Webhook and Pub/Sub notification channels.Cevap
- CInstall and configure the legacy Cloud Logging agent inside the Cloud Run container instance to aggregate application logs.
- DGrant the primitive Owner role to the Cloud Monitoring service account to enable cross-service event delivery to external Webhook channels.
Cevap
To measure log occurrence frequencies and trigger automated alerts in Google Cloud, the engineer must create a counter log-based metric in Cloud Logging filtered for the specific error payload, and then configure a Cloud Monitoring alerting policy targeting that metric with the appropriate notification channels attached.
Creating a counter log-based metric extracts numerical data from matching log patterns, allowing Cloud Monitoring to evaluate the occurrence rate. Setting up an alerting policy tied to this metric triggers notifications to configured Webhook and Pub/Sub channels when the count threshold is exceeded within the 5-minute window.
Adım Adım Çözüm
Anahtar Kavram
Log-based metrics bridge Cloud Logging and Cloud Monitoring by converting specific log search patterns into numerical time-series metrics suitable for alerting policies.