You are building and running client applications in Cloud Run and Cloud Functions. Your client requires that all logs must be available for one year so that the client can import the logs into their logging service. You must minimize required code changes. What should you do?
A. Update all images in Cloud Run and all functions in Cloud Functions to send logs to both Cloud Logging and the client’s logging service. Ensure that all the ports required to send logs are open in the VPC firewall.
B. Create a Pub/Sub topic, subscription, and logging sink. Configure the logging sink to send all logs into the topic. Give your client access to the topic to retrieve the logs.
C. Create a storage bucket and appropriate VPC firewall rules. Update all images in Cloud Run and all functions in Cloud Functions to send logs to a file within the storage bucket.
D. Create a logs bucket and logging sink. Set the retention on the logs bucket to 365 days. Configure the logging sink to send logs to the bucket. Give your client access to the bucket to retrieve the logs.
Disclaimer
This is a practice question. There is no guarantee of coming this question in the certification exam.
Answer
D
Explanation
A. Update all images in Cloud Run and all functions in Cloud Functions to send logs to both Cloud Logging and the client’s logging service. Ensure that all the ports required to send logs are open in the VPC firewall.
(Requires lots of code change, and not giving solution of retaining logs for one year.)
B. Create a Pub/Sub topic, subscription, and logging sink. Configure the logging sink to send all logs into the topic. Give your client access to the topic to retrieve the logs.
(Again, lots of work required in this approach. And not giving solution of retaining logs for one year.)
C. Create a storage bucket and appropriate VPC firewall rules. Update all images in Cloud Run and all functions in Cloud Functions to send logs to a file within the storage bucket.
(Unnecessary, as logs are already collected in Cloud Logging.)
D. Create a logs bucket and logging sink. Set the retention on the logs bucket to 365 days. Configure the logging sink to send logs to the bucket. Give your client access to the bucket to retrieve the logs.
(This approach abstracts the log storage from your applications running in Cloud Run and Cloud Functions, ensuring that logs are retained for the specified duration without requiring modifications to individual codebases. Additionally, providing your client access to the designated bucket allows them to retrieve the logs seamlessly. It’s a centralized and efficient solution that aligns with best practices for log management in Google Cloud.)