A payment-processing microservice runs on Cloud Run and writes structured JSON logs that include the field "event". SREs must raise an alert if more than 50 log entries with event="payment_failed" and severity=ERROR are recorded within any 5-minute window. They want the solution to require no code changes and to be maintainable through the Cloud Console. Which approach should they take?
Deploy the Ops Agent to the Cloud Run revision and configure it to count payment_failed log lines, then alert on the collected metric.
Create a log-based counter metric in Cloud Logging that matches the error filter, then build an alerting policy on the new custom metric.
Add OpenTelemetry instrumentation to the service to emit a custom metric, and configure an alert on that metric.
Enable Cloud Trace for the project and configure a custom error-rate detector based on collected traces.
A log-based counter metric lets you create a custom Monitoring metric directly from log entries by defining a filter such as severity=ERROR AND jsonPayload.event="payment_failed". The metric increments automatically whenever a matching log arrives, can be charted and used in an alerting policy, and requires no changes to the Cloud Run service. Instrumenting the code with OpenTelemetry or custom exporters would meet the requirement but adds code changes and build/deploy work. The Ops Agent cannot be installed on Cloud Run-managed instances, and Cloud Trace does not count arbitrary log messages.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a log-based counter metric in Cloud Logging?
Open an interactive chat with Bash
What is OpenTelemetry, and why wasn't it used in this solution?
Open an interactive chat with Bash
Why can't the Ops Agent be installed on Cloud Run-managed instances?
Open an interactive chat with Bash
What is a log-based counter metric in Cloud Logging?
Open an interactive chat with Bash
What is OpenTelemetry instrumentation, and why is it not ideal in this scenario?
Open an interactive chat with Bash
Why can't the Ops Agent be used on Cloud Run instances?
Open an interactive chat with Bash
GCP Associate Cloud Engineer
Ensuring successful operation of a cloud solution
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .