An online retailer runs a Cloud Run service. Each time a payment fails, the application writes a structured log entry with severity ERROR and the field payment_status="DECLINED". You must alert the on-call team whenever 20 or more such failures occur within any one-minute window, and you cannot modify application code or deploy additional services. What is the most efficient way to deliver this alert?
Create an uptime check that polls the Cloud Run service endpoint every minute and configure an alert to fire if 20 or more requests return a 5xx status within the last minute.
Enable Cloud Audit Logs for Cloud Run, create a distribution logs-based metric on all audit log entries, and configure an alert that triggers when the metric's 95th-percentile value exceeds 20.
Use Logs Explorer to filter for resource.type="cloud_run_revision" AND severity=ERROR AND jsonPayload.payment_status="DECLINED", create a counter logs-based metric, then build a Cloud Monitoring alerting policy that fires when the metric's rate exceeds 20 per minute.
Export the filtered logs to Pub/Sub, invoke a Cloud Function that increments a custom Cloud Monitoring metric for each message received, and set an alert on that metric when it exceeds 20 per minute.
Because the required signal is already present in Cloud Logging, the simplest solution is to create a counter logs-based metric whose filter selects only the payment-failure log entries. Logs-based metrics are generated directly by Cloud Logging, automatically appear in Cloud Monitoring as custom metrics, and can be used in alerting policies without additional infrastructure. A distribution metric is unnecessary for a pure event count, and exporting logs to an external service or implementing uptime checks would add complexity and cost while still requiring a metric to be created elsewhere.
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 logs-based metric?
Open an interactive chat with Bash
How does a counter logs-based metric differ from a distribution metric?
Open an interactive chat with Bash
What is the role of Cloud Monitoring in alerting?
Open an interactive chat with Bash
What is a logs-based metric in GCP?
Open an interactive chat with Bash
How does Logs Explorer filter logs in Cloud Run?
Open an interactive chat with Bash
What is the benefit of using Cloud Monitoring alerting policies with logs-based metrics?
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
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .