Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Question 35 of 108
Free Preview · 108 of 359 · questions 1–108 of 359 are free. Sign up free to sync your progress across devices.
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
The correct answer is: A. Add a Stackdriver counter metric for path:/api/alpha/ Explanation: A. Add a Stackdriver counter metric for path:/api/alpha/: This option is effective because Stackdriver (now known as Google Cloud Monitoring) supports creating custom metrics that can count log entries matching specific patterns in log fields, such as path:/api/alpha/. By adding a counter metric for the path field, you can automatically track the count of all requests to /api/alpha/* without needing to export and process the logs externally. Why Not the Other Options? B. Add a Stackdriver counter metric for endpoint:/api/alpha/: This answer is ambiguous and less likely to work, as "endpoint" is not a standard log field in Stackdriver. Instead, path or httpRequest.requestUrl would be the correct field to use.
The best approach here is A. Add a Stackdriver counter metric for path:/api/alpha/. Here's why: Stackdriver Metrics: Stackdriver metrics are specifically designed for tracking and aggregating data points over time. They are ideal for counting events like requests. Path-Based Filtering: You can define Stackdriver metrics with specific filters based on the request path. In this case, path:/api/alpha/ will capture all requests matching that pattern. Efficient Aggregation: Stackdriver automatically aggregates the metric data, providing you with the total count of requests to the /api/alpha/* endpoints.
Why other options are less suitable: **B. Endpoint:/api/alpha/*: ** While this might seem like a good option, Stackdriver doesn't typically use the term "endpoint" for filtering. It primarily uses "path" for request path-based filtering. C. Export logs to Cloud Storage and count lines: This is a less efficient and more complex approach. You'd need to write custom code to parse the logs and count the matching lines, which adds overhead and potential for errors. D. Export logs to Cloud Pub/Sub and count lines: Similar to option C, this involves exporting logs and then processing them externally, which is less efficient than using Stackdriver metrics. In summary: Adding a Stackdriver counter metric with the path:/api/alpha/ filter is the most efficient and straightforward way to get the count of all requests on all /api/alpha/* endpoints.