Soru

Zorluk: ZorMonitoring and Logging

A DevOps engineer needs to configure automated real-time alerts whenever a specific error pattern (`[ERROR] Database connection failed`) is written to a custom application log file on a fleet of Compute Engine virtual machines. The solution must adhere to current Google Cloud recommended practices and follow the principle of least privilege. Which set of steps should the engineer execute?

  1. Install the Google Cloud Ops Agent on the virtual machines, configure a custom log receiver in config.yaml to ingest the log file path, create a counter log-based metric in Cloud Logging for the error pattern, and set up a Cloud Monitoring alerting policy based on that metric.Cevap
  2. B
    Install the legacy Stackdriver Logging Agent on the virtual machines, configure an Uptime Check in Cloud Monitoring targeting the local log file directory, and configure an alert policy triggered by disk I/O metrics.
  3. C
    Install the Google Cloud Ops Agent on the virtual machines, assign the primitive Owner role to the Compute Engine default service account, and construct a custom script to poll Cloud Logging via gcloud commands every minute.
  4. D
    Enable the Cloud Logging and Cloud Monitoring APIs at the Google Cloud Organization resource level, leave them disabled in the host project, and configure an organization policy to forward log errors to Cloud Monitoring.

Cevap

The engineer should install the Google Cloud Ops Agent on the virtual machines, configure a custom log receiver in `config.yaml` for the log file path, create a counter log-based metric in Cloud Logging matching the error string, and set up an alerting policy in Cloud Monitoring based on that metric.
To monitor custom local application logs on Compute Engine VMs, the Google Cloud Ops Agent must be installed and configured with a file receiver in `config.yaml`. To trigger alerts on specific text patterns inside those logs, a counter log-based metric must be created in Cloud Logging to convert matching log entries into time-series metric data. Finally, a Cloud Monitoring alerting policy can be configured on that metric threshold.

Adım Adım Çözüm

1
Deploy and configure the Google Cloud Ops Agent telemetry collector
The Ops Agent streams custom application log files from the Linux filesystem to Cloud Logging.
Google Cloud Ops Agent is the recommended unified telemetry agent for Compute Engine VMs.
2
Define a counter log-based metric in Cloud Logging
Cloud Logging counts occurrences of incoming log entries matching the filter expression `textPayload:"[ERROR] Database connection failed"`.
Log-based metrics extract quantitative data from log streams so Cloud Monitoring can track and trigger alerts on specific log events.
3
Create a Cloud Monitoring Alerting Policy
An alert notification is dispatched when the log-based metric count exceeds the specified threshold.
Cloud Monitoring alerting policies monitor metric thresholds and notify operators of operational issues.

Anahtar Kavram

Log-Based Metrics and Ops Agent Configuration for Compute Engine Observability
Bu soruyu puanla