Monitoring API Requests in Stackdriver | SEO for Exam Preparation

Counting Requests on /api/alpha/ Endpoints | SEO Tips for Exam Success

Question

Your application is logging to Stackdriver.

You want to get the count of all requests on all /api/alpha/* endpoints.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

Option A and Option B both involve adding a Stackdriver counter metric, which is used to track the number of occurrences of a particular event over a specified period. However, the two options differ in the metric being tracked.

Option A suggests adding a counter metric for path:/api/alpha/, which means that the metric will track the number of requests made to the /api/alpha/ path. This option will not capture requests made to any endpoints nested under /api/alpha/.

Option B suggests adding a counter metric for endpoint:/api/alpha/, which means that the metric will track the number of requests made to all endpoints nested under /api/alpha/. This option is a better fit for the given requirement of tracking requests made to all /api/alpha/ endpoints.

Option C involves exporting the logs to Cloud Storage and counting the lines that match /api/alpha. This option requires more manual effort and is less efficient than Option A or Option B.

Option D involves exporting the logs to Cloud Pub/Sub and counting the lines that match /api/alpha. This option is similar to Option C and is also less efficient than Option A or Option B.

Therefore, the correct answer is Option B - Add a Stackdriver counter metric for endpoint:/api/alpha/*. This option will accurately track the number of requests made to all endpoints nested under /api/alpha/.