Google Associate Cloud Engineer Question 300
Single answerGoogle Cloud PlatformYou are a Google Cloud Engineer tasked with monitoring and troubleshooting an application running on Google Kubernetes Engine (GKE). You need to filter logs in Cloud Logging to investigate a specific error that occurred yesterday. Which of the following filter expressions would you use to view only the ERROR logs from your GKE cluster for that day?
- A
resource.type="k8s_container" severity="ERROR" timestamp>="2023-10-11T00:00:00Z" timestamp<"2023-10-12T00:00:00Z"
- B
resource.labels.cluster_name="my-cluster" severity="ERROR" timestamp="2023-10-11"
- C
resource.type="gce_instance" severity="ERROR" timestamp>="2023-10-11T00:00:00Z" timestamp<"2023-10-12T00:00:00Z"
- D
resource.type="k8s_container" severity="ERROR" timestamp>="2023-10-10T00:00:00Z" timestamp<"2023-10-11T00:00:00Z"
Show answer and explanation
Correct answer: A
Explanation
To filter logs in Cloud Logging for a specific time period and severity, you need to specify the correct resource type, severity level, and a timestamp range that covers the entire day you are interested in. The first option correctly uses 'k8s_container' as the resource type, 'ERROR' for the severity, and a timestamp range that includes all logs for the specified day.
- A. Correct.
This filter expression correctly specifies the resource type as 'k8s_container', the severity level as 'ERROR', and the timestamp range for the logs from yesterday.
- B. Incorrect.
This option incorrectly specifies the timestamp as a single date instead of a range, which will not correctly filter for all logs within that day.
- C. Incorrect.
This filter incorrectly uses 'gce_instance' as the resource type, which is not relevant for a GKE cluster.
- D. Incorrect.
This filter expression incorrectly specifies the timestamp range as the day before yesterday.