
Answer-first summary for fast verification
Answer: Add a Stackdriver counter metric for path:/api/alpha/.
To accurately count all requests to endpoints under `/api/alpha/*`, the most efficient method is to utilize Stackdriver's log-based metrics. This involves creating a counter metric that filters log entries based on the request path. Option A suggests using a filter for `path:/api/alpha/`, which is the correct approach as it will match all subpaths under `/api/alpha/`. This method is real-time and does not require exporting logs to external services like Cloud Storage or Cloud Pub/Sub, which are less efficient and not suitable for real-time counting. Therefore, option A is the correct answer.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
To retrieve the count of all requests to endpoints matching /api/alpha/* in Stackdriver logs, what steps should you follow?
(Optional code block if applicable, corrected for syntax/typos):
# Example filter for Stackdriver Logging query
resource.type="gae_app"
logName="projects/[PROJECT_ID]/logs/appengine.googleapis.com%2Frequest_log"
jsonPayload.resource LIKE "/api/alpha/%"
# Example filter for Stackdriver Logging query
resource.type="gae_app"
logName="projects/[PROJECT_ID]/logs/appengine.googleapis.com%2Frequest_log"
jsonPayload.resource LIKE "/api/alpha/%"
What is the correct approach to achieve this?
A
Add a Stackdriver counter metric for path:/api/alpha/.
B
Add a Stackdriver counter metric for endpoint:/api/alpha/*.
C
Export the logs to Cloud Storage and count lines matching /api/alpha.
D
Export the logs to Cloud Pub/Sub and count lines matching /api/alpha.