ASSOCIATE-CLOUD-ENGINEER practice question 10 of 35

For analysis purposes, you need to send all the logs from all of your Compute Engine instances to a BigQuery dataset called platform-logs. You have already installed the Stackdriver Logging agent on all the instances. You want to minimize cost. What should you do?

Full set: 332 questions
Answer options
A: 1. Give the BigQuery Data Editor role on the platform-logs dataset to the service accounts used by your instances.2. Update your instances’ metadata to add the following value: logs-destination: bq://platform-logs.
B: 1. In Stackdriver Logging, create a logs export with a Cloud Pub/Sub topic called logs as a sink.2. Create a Cloud Function that is triggered by messages in the logs topic.3. Configure that Cloud Function to drop logs that are not from Compute Engine and to insert Compute Engine logs in the platform-logs dataset.
C: 1. In Stackdriver Logging, create a filter to view only Compute Engine logs.2. Click Create Export.3. Choose BigQuery as Sink Service, and the platform-logs dataset as Sink Destination. Correct answer
D: 1. Create a Cloud Function that has the BigQuery User role on the platform-logs dataset.2. Configure this Cloud Function to create a BigQuery Job that executes this query:INSERT INTO dataset.platform-logs (timestamp, log)SELECT timestamp, log FROM compute.logsWHERE timestamp > DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)3. Use Cloud Scheduler to trigger this Cloud Function once a day.
Correct Answer:
C. 1. In Stackdriver Logging, create a filter to view only Compute Engine logs.2. Click Create Export.3. Choose BigQuery as Sink Service, and the platform-logs dataset as Sink Destination.
Explanation

The most direct, cost-effective, and officially recommended method to send logs from Cloud Logging to BigQuery is by creating a log sink. A sink allows you to define a filter for specific logs (in this case, from Compute Engine instances using resource.type="gceinstance") and route them directly to a supported destination. Choosing BigQuery as the sink destination is a native integration that is optimized for this purpose. This approach avoids the additional cost and complexity of intermediate services like Pub/Sub and Cloud Functions, thereby minimizing both operational overhead and cost, as required by the question.

Why Incorrect

A. The instance metadata key logs-destination is not a valid or standard configuration parameter for the Cloud Logging agent to specify a BigQuery destination.
B. This solution introduces unnecessary intermediate services (Pub/Sub and Cloud Functions), which add complexity and incur their own costs for message delivery and function execution, violating the "minimize cost" requirement.
D. This describes a complex, daily batch process. It introduces latency (up to 24 hours), is more expensive due to using Cloud Scheduler and Cloud Functions, and is less reliable than a real-time sink.

References

1. Google Cloud Documentation - Overview of log routing and sinks: "To route logs

you create a sink. A sink includes a destination and a filter that selects the log entries to route... You can route log entries to the following destinations: ... BigQuery dataset". This document establishes the sink as the primary mechanism for routing logs.

Source: Google Cloud Documentation

"Overview of log routing and sinks"

Section: "How sinks work".

2. Google Cloud Documentation - Exporting logs to BigQuery: "To export logs to BigQuery

you create a sink and set BigQuery as the destination... The sink creates a new BigQuery dataset and then creates tables with a schema for the logs." This page details the exact procedure described in option C.

Source: Google Cloud Documentation

"Route logs to supported destinations"

Section: "Route logs to BigQuery".

3. Google Cloud Documentation - Cloud Logging Pricing: "There is no charge for routing logs to a supported destination; however

the destination might have its own ingestion costs." This supports the cost-minimization argument by showing that the routing itself is free

so avoiding extra billable services (like Pub/Sub and Functions) is the most economical approach.

Source: Google Cloud Documentation

"Cloud Logging pricing"

Section: "Log routing".

4. Google Cloud Documentation - Logging agent configuration: The official documentation for configuring the google-fluentd agent does not list a logs-destination metadata key for routing logs

confirming that the method in option A is incorrect. Configuration is managed through agent configuration files

not instance metadata for this purpose.

Source: Google Cloud Documentation

"Logging agent - Advanced configuration".

Scroll to Top