Google Professional Cloud DevOps Engineer Question 247
Select 2Google Cloud PlatformYour team has implemented a new feature in your application that writes specific structured logs to Cloud Logging whenever a critical event occurs. You want to track the frequency of these critical events over time and create an alert if their count exceeds a predefined threshold. How can you achieve this in Google Cloud?
- A
Create a log-based metric in Cloud Logging to count the occurrences of the critical event.
- B
Use Cloud Monitoring to create a custom dashboard that directly queries the structured logs for the critical event.
- C
Set up a Cloud Monitoring alert policy based on the log-based metric to notify you when the event count exceeds the threshold.
- D
Export the logs to BigQuery and write a SQL query to determine the frequency of critical events, then create a custom alert in BigQuery.
- E
Create a log sink to export the logs to Cloud Storage and use a third-party tool to analyze the frequency of the critical events.
Show answer and explanation
Correct answers: A, C
Explanation
To track the frequency of critical events and set up alerts, you need to create a log-based metric in Cloud Logging that counts occurrences of the event. Afterward, you can use Cloud Monitoring to create an alert policy based on this metric. This approach leverages Google Cloud's native tools for logs-based monitoring and alerting, making it the most efficient and recommended solution.
- A. Correct.
Correct: Creating a log-based metric allows you to extract specific information from your logs, such as the count of critical events, which you can then use in Cloud Monitoring.
- B. Incorrect.
Incorrect: While you can create custom dashboards in Cloud Monitoring, directly querying logs is not a supported method for creating metrics or alerts. Log-based metrics must first be created to track specific patterns in logs.
- C. Correct.
Correct: Once you have a log-based metric, you can configure an alert policy in Cloud Monitoring to notify you when the count exceeds a threshold.
- D. Incorrect.
Incorrect: Exporting logs to BigQuery can be useful for advanced analysis, but it is unnecessary here. Log-based metrics in Cloud Logging are the recommended approach for this use case.
- E. Incorrect.
Incorrect: Exporting logs to Cloud Storage and using a third-party tool is not efficient for operational monitoring and alerting. Google Cloud provides native tools like log-based metrics and Cloud Monitoring for this purpose.