
Answer-first summary for fast verification
Answer: Change your application’s logging library to the Cloud Logging library, and configure your application to export logs to Cloud Logging.
The simplest method to include request metadata in logs exported to Cloud Logging is to use the Cloud Logging library. GKE's default logging agent already collects stdout logs, but they lack structured metadata. The Cloud Logging library automatically captures contextual metadata (e.g., trace IDs, HTTP request details) without manual code changes for each log statement. Option B requires modifying the application to output JSON with metadata, which is feasible but less efficient, as it involves manual addition of metadata. Options C (CSV) and D (Fluent Bit) are invalid, as CSV isn't structured for Cloud Logging, and GKE already has a logging agent. Using the Cloud Logging library (A) ensures seamless integration and automatic metadata handling.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have an application running on Google Kubernetes Engine (GKE) that currently logs to standard output using a logging library. You need to export these logs to Cloud Logging while ensuring each log entry includes request metadata. What is the simplest method to achieve this?
A
Change your application’s logging library to the Cloud Logging library, and configure your application to export logs to Cloud Logging.
B
Update your application to output logs in JSON format, and add the necessary metadata to the JSON.
C
Update your application to output logs in CSV format, and add the necessary metadata to the CSV.
D
Install the Fluent Bit agent on each of your GKE nodes, and have the agent export all logs from /var/log.
No comments yet.