Soru

Zorluk: OrtaMonitoring and Logging

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.)

  1. Create a counter log-based metric in Cloud Logging using a log filter matching the specific error code.Cevap
  2. Create a Cloud Monitoring alerting policy based on the log-based metric threshold and configure Webhook and Pub/Sub notification channels.Cevap
  3. C
    Install and configure the legacy Cloud Logging agent inside the Cloud Run container instance to aggregate application logs.
  4. D
    Grant 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

1
Define a filter in Cloud Logging for the target log entries and extract them as a metric.
A counter log-based metric named after the error is created in Cloud Logging.
Log-based metrics convert log data matching specific query filters into numeric metric time-series data readable by Cloud Monitoring.
2
Configure an alerting policy in Cloud Monitoring.
An alert condition monitors the counter metric, triggering when count > 10 over a 5-minute rolling window.
Cloud Monitoring alerting policies evaluate metric thresholds and route incident alerts to configured Webhook and Pub/Sub notification channels.

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.
Bu soruyu puanla