Repository navigation
fix(monitoring): size the Cloud Run metrics exporter for a real collection - #12146
Merged
Merged
Conversation
…ction The exporter was sized for the case where it had nothing to collect. It ran healthy for a day because prod Cloud Monitoring held zero omi_ descriptors, then died the morning prod backend started serving a GMP sidecar: 120 restarts, up=0, scrape_samples_scraped=0, and scrape_duration_seconds pinned at exactly the 10s Prometheus timeout. A real prod scrape is ~28MB and 52,662 series and takes 6-10s, with steady-state usage of 238m CPU and 331Mi -- already above the 200m/256Mi ceiling. Because this exporter queries Cloud Monitoring inline at scrape time, that throttling also stalled the '/' path both probes hit, so kubelet killed it mid-collection before it could deliver one sample. Raise limits to 2 CPU / 2Gi, give the probes 25s so they outlast a scrape, set the job to a 60s interval with an explicit 45s timeout, and drop the _created timestamp series that are 36% of everything imported and answer no question. Dev gets the same treatment: it is measured at 6.26s against the same 10s budget. Add omi-cloud-run-egress-down. The existing query-rejected alert cannot see this failure: a crashlooping exporter publishes no error metric, so an error-based rule reads healthy -- the same "healthy because idle" shape as the outage, inside the alert written to prevent it.
Git-on-my-level
added a commit
that referenced
this pull request
Aug 24, 2026
…12150) prometheus-stackdriver-exporter hardcodes livenessProbe and readinessProbe in its Deployment template with a fixed 10s timeout and exposes no values key for either, in 4.8.3 and every later 4.x. The probe block added in #12146 therefore renders nothing. The live dev reconcile is what showed it: the exporter picked up the new cpu: 2 / memory: 2Gi limits and kept serving timeoutSeconds: 10. A stanza that reads as configuration, changes nothing, and reverts silently is worse than none, and the contract test asserting it could never have failed for a real reason. Remove both blocks, record that the chart owns the probes and that CPU is the only lever over probe survival, and invert the test so re-adding an inert block fails with that reason. Capacity was always the operative half of #12146 and still stands: the probes hit '/', so they only time out when the process is starved. Co-authored-by: r <r@r>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 31, 2026
…12446) ## Why this change On 2026-08-30 a voice-capture outage left `capture_finalization` success at **0% for hours** while every existing critical stayed Normal: listen ready=5, listen WS≈325, pusher WS≈326, LB traffic flowing, 5xx rps=0. The existing criticals only watch zero LB traffic, zero ready pods, WS < 10, and 5xx rates. The rules that did read user outcomes (`omi-journey-*-fail`, #11991) are **warning-class**, and the [Omi Core Features dashboard](https://monitor.omi.me/d/omi-core-features/omi-core-features) that plots these SLIs is visualization-only — panel thresholds, zero alert rules. **Dashboard ≠ alert**: the signal existed, nothing paged on it. Incident fingerprint (last 1h at peak): `omi_journey_terminal_total{journey="capture_finalization"}` success=0, failure≈360, stale≈290; accepted≈750; oldest unfinished finalization job ≈ 5.9 days; dead letters ≈ 2.5k/24h. ## What was added Six `severity: critical` rules in the `Resilience` group (split source `backend/charts/monitoring/alerts/resilience.json`, mirrored into the combined `backend/charts/monitoring/alert-rules.json`), plus one rule change. Every rule links the Core Features panel that plots its own signal. | Metric / SLI | Existing rule (git = live mirror) | False-negative class this incident hit | New / changed UID | noDataState | Traffic gate | |---|---|---|---|---|---| | `capture_finalization` success share | `omi-journey-capture-fail` (warning, #11991; reads `listen_finalization_durable_jobs` deltas) | warning-class — ticket lane, no page; incident kept it out of the paging path | `omi-journey-capture-success-critical` | `NoData` | ≥ 20 accepted / 30m | | accepted-without-terminal (accepted vs settled) | `omi-capture-finalization-dead-emission` (warning; fires only on **zero** terminal movement) | incident had *flowing* failure/stale terminals, so the zero-terminal condition never applied at page class | `omi-journey-capture-settle-gap` | `NoData` | ≥ 100 accepted / 1h | | `listen_finalization_dead_letter_total` | **missing** (dashboard panel only) | ~2.5k dead letters/day with zero alerts reading it | `omi-capture-dead-letter-surge` | `Alerting` | none — each dead letter is a lost capture (> 50/1h) | | `listen_finalization_oldest_nonterminal_age_seconds` | **missing** (backlog panel from #12211 only) | oldest job aged to 5.9 days with zero alerts reading it | `omi-capture-oldest-nonterminal` | `Alerting` | none — queue age is traffic-independent (> 3600s) | | `pusher_session` success share | `omi-journey-pusher-fail` (warning) | warning-class only | `omi-journey-pusher-success-critical` | `NoData` | ≥ 20 accepted / 30m | | `chat_response` success share | `omi-journey-chat-fail` (warning; unfirable for its whole life before the Cloud Run bridge) | warning-class + counter historically absent from Prometheus | `omi-journey-chat-success-critical` | `NoData` | ≥ 20 accepted / 30m | | journey counter liveness | `omi-journey-signal-dead` covered only `pusher_session\|capture_finalization`; `chat_response` exempt | a dead chat counter would silently disarm every chat alert (the exact 2026-08-19 hole) | `omi-journey-signal-dead` **changed** — adds a `chat_response` arm | `Alerting` | chat arm gated on `llm_gateway_requests_total{lane_id="omi:auto:chat-agent"} > 20/1h` | ### PromQL Success-rate rules pair numerator and denominator from the same emitter (`omi_journey_terminal_total` for one `journey`), gated on that journey's accepted counter (example: capture): ```promql # A — gate sum(increase(omi_journey_accepted_total{journey="capture_finalization"}[30m])) # B — success share (a total terminal stall with real traffic reads 0 and pages) sum(increase(omi_journey_terminal_total{journey="capture_finalization",outcome="success"}[30m])) / clamp_min(sum(increase(omi_journey_terminal_total{journey="capture_finalization",outcome=~"success|failure"}[30m])), 1) # C — $A >= 20 && $B < 0.90, for 10m ``` Settle gap (accepted minus all terminal outcomes, 1h): `$A >= 100 && $B > 50`, for 15m. Oldest job: `max(listen_finalization_oldest_nonterminal_age_seconds) > 3600`, for 15m. Dead letters: `sum(increase(listen_finalization_dead_letter_total[1h])) > 50`, for 15m. Liveness chat arm (added to `omi-journey-signal-dead`): ```promql or (sum by (journey) (increase(omi_journey_accepted_total{journey="chat_response"}[1h])) < bool 1) * on() group_left() (sum(increase(llm_gateway_requests_total{lane_id="omi:auto:chat-agent"}[1h])) > bool 20) ``` ### noData semantics - Success-rate and gap rules: `NoData` (the documented `traffic_gated_journey` class) — missing series are visible as NoData, never healthy; counter death pages via `omi-journey-signal-dead` and `omi-journey-scrape-missing`. - Queue rules (`oldest-nonterminal`, `dead-letter`): `Alerting` — both series are unlabeled and zero-initialized on every backend-listen replica, so absence during real traffic means the emitter or its scrape is gone. Documented as `finalization_queue_health` in `expected-targets.prod.yaml`. ### Threshold calibration (documented in `backend/docs/runbooks/real-traffic-journeys.md`) - 0.90 paging floor vs the dashboard's 95/99 display thresholds; the incident sat at 0%. - ≥ 20 accepted/30m gate (same floor the existing warning rules use); the incident ran ~375 accepted/30m. - Gap > 50/h at ≥ 100 accepted/h: the incident left ~100/h accepted-but-never-settled; healthy in-flight work settles in minutes. - Oldest job > 1h: healthy drain is minutes; incident oldest was ~5.9 days. - Dead letters > 50/h: incident ran ~104/h (2.5k/day). - Chat liveness gate > 20/h sits above the chat-agent lane's measured p05 (min 9, p01 15, p05 23, median 55 req/h over 7 prod days), so quiet hours do not page. These are incident-calibrated initial values; replay them against production history when importing (the repo has no live Prometheus access from a PR-checkout environment). ## Live vs git reconciliation - Live Grafana (issue-verified 2026-08-30 ~23:30 UTC): **68 unified rules**; git before this PR: **80**. The 12-rule delta is recently merged rules not yet imported (Firestore #12193/#12201/#12241, cloud-run ingestion #11998/#12146, etc.) — the documented apply path is a maintainer import of `alert-rules.json`; no CI writes Grafana, and this PR follows that path (no API writes). - The pre-incident journey rules (from #11991, merged 2026-08-22) predate the outage window; their gap was severity class, not presence. - Metric label sets were discovered from the emitter contract, not guessed: `utils/metrics.py`, `utils/observability/journeys.py` (`journey` ∈ {`chat_response`, `pusher_session`, `capture_finalization`}; `outcome` ∈ {`success`, `failure`, `cancelled`, `stale`}), `services/conversation_finalization.py` (unlabeled dead-letter counter, unlabeled oldest-age gauge, `state`-labeled durable gauge), and the closed vocabulary in `backend/docs/runbooks/real-traffic-journeys.md`. Direct live Prometheus/Grafana queries were not available from this environment (auth required); the `chat_response` ingestion path is evidenced by #12146's measured live prod scrape (~28MB, 52,662 `omi_*` series). ## Tests Extended `test_monitoring_alert_rule_contract.py`: - `LIVENESS_EXEMPT_JOURNEYS` is now empty — the `chat_response` exemption's own deletion clause fired once the Cloud Run bridge was verified live; `test_every_alerted_journey_is_covered_by_the_liveness_rule` now enforces chat coverage instead. - New: `test_page_class_journey_rules_cover_the_capture_outage_fingerprint` (severity, component, noData, `for` window, receiver, exact math gates), `test_page_class_success_rules_pair_numerator_and_denominator_from_one_emitter`, `test_finalization_queue_rules_read_the_replicated_series_correctly` (max-aggregation for the replicated gauge). ## Verification ```bash cd backend && .venv/bin/python -m pytest \ tests/unit/test_journey_observability.py \ tests/unit/test_monitoring_alert_rule_contract.py \ tests/unit/test_monitoring_dashboard_absence_contract.py \ tests/unit/test_monitoring_telemetry_contract.py -q # 63 passed (the exact set scripts/select_backend_unit_tests.py selects for these changed files) make preflight # PR preflight passed: 11 checks in 28.55s ``` Closes SCA-379 <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12446?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
pull Bot
pushed a commit
to AmirulAndalib/omi
that referenced
this pull request
Aug 31, 2026
The 2026-08-30 capture-finalization outage sat at 0% success for hours (failure ~360/h, stale ~290/h, accepted ~750/h, oldest job ~5.9d, dead letters ~2.5k/day) while every listen/pusher critical stayed Normal: they only watch LB traffic, ready pods, WS counts, and 5xx rates. The journey rules that did read user outcomes were warning-class (BasedHardware#11991), and the Core Features dashboard tiles were visualization-only. Add six severity:critical rules plus liveness coverage for chat: - omi-journey-capture-success-critical / -pusher- / -chat-: success share < 0.90 for 10m at >= 20 accepted/30m (numerator and denominator from the same omi_journey_terminal_total emitter) - omi-journey-capture-settle-gap: accepted - settled > 50/h at >= 100 accepted/h for 15m - omi-capture-oldest-nonterminal: max age > 3600s for 15m - omi-capture-dead-letter-surge: > 50 dead letters/h for 15m - omi-journey-signal-dead now covers chat_response behind a chat-agent lane gate (> 20/h, above the lane's measured p05); the LIVENESS_EXEMPT_JOURNEYS entry is deleted per its own instruction now that the Cloud Run metrics bridge is verified live (BasedHardware#11998, BasedHardware#12146) Contract tests pin severity, components, gates, noData semantics, and single-emitter pairing; expected-targets documents the new finalization_queue_health: Alerting no-data class; runbooks updated. Verification: pytest tests/unit/test_journey_observability.py tests/unit/test_monitoring_alert_rule_contract.py tests/unit/test_monitoring_dashboard_absence_contract.py tests/unit/test_monitoring_telemetry_contract.py -> 63 passed; make preflight -> 11 checks passed. Co-authored-by: multica-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Cloud Run metrics exporter was sized for an exporter that had nothing to collect. The moment prod actually had Cloud Run metrics, it died — 120 restarts,
up=0,scrape_samples_scraped=0— and everyomi_*series stopped at the bridge.This sizes it from measurement, gives the scrape a budget that fits a real collection, drops 36% of the imported series as pure noise, and adds the alert that would have caught it.
What happened
prod-omi-cloud-run-metrics-exporterwas installed on 2026-08-23 at 18:01 and looked healthy for a day, because prod Cloud Monitoring had zeroomi_*descriptors — there was nothing to fetch. When prodbackendbegan serving a GMP sidecar revision at 05:58 the next morning, 27 descriptors appeared and the exporter started doing real work. Measured, on the live pod:scrape_duration_secondsscrape_samples_scrapedup{job="cloud-run-application-metrics"}CrashLoopBackOff, 120 restartsLiveness probe failed: ... context deadline exceededThis exporter queries Cloud Monitoring inline, at scrape time, so a large collection makes the entire HTTP server slow — including the
/path both probes hit. Under a 200m CPU ceiling the process was throttled hard enough to miss the 10s liveness timeout, and kubelet killed it mid-collection before it could deliver a single sample.Changes
Capacity, both environments. Requests 50m/64Mi → 200m/256Mi; limits 200m/256Mi → 2 CPU/2Gi. The measured steady state already exceeded the old ceiling. For reference, the sibling
*-omi-prometheus-stackdriver-exporterthat has run healthily for six days has no limits at all.Probes, both environments.
timeoutSeconds10 → 25,periodSeconds10 → 30,failureThreshold3 → 5. A probe shorter than a scrape converts latency into a crash loop.Scrape budget, both environments.
scrape_interval30s → 60s and an explicitscrape_timeout: 45s. The default 10s timeout cut every prod collection off mid-flight.Drop
_created. Client libraries emit a_createdtimestamp beside every counter. They survive the rename asomi_*_createdand are 19,087 of 52,607 prod series (36%) while answering no question any alert or dashboard asks.New alert
omi-cloud-run-egress-downonup < 1for 15m, absent-counts-as-down.Why the existing alert did not catch this
omi-cloud-run-egress-query-rejected— added two PRs ago for exactly this class — watchesstackdriver_monitoring_last_scrape_error. A crashlooping exporter publishes no metric at all, soor vector(0)evaluates to 0 and the rule reads healthy. An error-based rule cannot see a process that never gets far enough to report an error. That is the same "healthy because it has nothing to do" shape as the outage itself, reproduced inside the alert written to prevent it. Hence a liveness rule alongside the error rule, with absence treated as down rather than as no-data.Verification
up0 → 1,scrape_duration_seconds10.013 → 4.79, and 52,607omi_*series now import under their plain names with zero un-normalized leak. Real traffic confirmed, not just series existence:mobile_chatandapp_webhook_deliverysuccesses over 15m.test_cloud_run_metrics_exporter_can_outlast_its_own_scrapeasserts capacity and probe floors in both environments. Floors rather than exact values, so capacity can be raised later without editing the test.cpu: 200mfails that test with the measured reason attached.test_monitoring_telemetry_contract.py,test_monitoring_alert_rule_contract.py,test_cloud_run_metrics_egress_workflow.py: 51 passed.alert-rules.jsonverified structurally: 73 → 74 rules, exactly one UID added, zero pre-existing rules altered, split source byte-identical, all UIDs within Grafana's 40-character limit.Product invariants affected
Monitoring-only. No serving authority, routing pin, or application surface is touched; this changes the capacity of a read-only metrics reader and the Prometheus job that scrapes it.
Failure-Class: FC-bridge-liveness-without-data-path-proof