Repository navigation
fix(monitoring): Grafana SQLite WAL + lock retries, external Grafana dead-man - #21306
Conversation
Enable WAL and increase the SQLite query and transaction retry budgets for Grafana 12.1.0 in dev and prod, preserving the existing database and PVC. Reconcile a multi-region Cloud Monitoring health check and five-minute failure policy through the approved prod monitoring workflow. Require MONITORING_DEADMAN_NOTIFICATION_CHANNELS and document rollout prerequisites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Require more than one failed checker location for five minutes after next-older alignment and count-false reduction grouped by check ID. Patch only drifted mutable uptime fields and reject immutable drift with manual delete-and-recreate remediation. Enforce real API field allowlists and multi-location alert semantics in the regression tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff1195e044
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "comparison": "COMPARISON_GT", | ||
| "thresholdValue": 1, | ||
| "duration": "300s", | ||
| "aggregations": [{"alignmentPeriod": "60s", "perSeriesAligner": "ALIGN_NEXT_OLDER", "crossSeriesReducer": "REDUCE_COUNT_FALSE", "groupByFields": ["metric.label.check_id"]}], |
There was a problem hiding this comment.
Count failing regions rather than checker locations
When two U.S. checker locations fail while Europe and Asia Pacific remain healthy, REDUCE_COUNT_FALSE produces 2, so this > 1 condition pages for an outage confined to one selected region. The USA selection expands to three distinct checkers, while Europe and Asia Pacific each have one, as documented in Google's uptime-check documentation; therefore this does not provide the intended regional quorum and disproportionately treats U.S. failures as global. Encode a region-level quorum rather than reducing all checker-location series directly.
Useful? React with 👍 / 👎.
| if immutable: | ||
| raise RuntimeError( | ||
| f'Uptime check {name} has immutable field drift: {", ".join(immutable)}. ' | ||
| 'Manual remediation: delete and recreate the uptime check, then rerun ' |
There was a problem hiding this comment.
Remove the alert-policy dependency before deleting the check
When any managed immutable field drifts after the policy has been created, this remediation cannot be followed as written: the policy filter references the existing check ID, and the Monitoring API explicitly rejects deleting an uptime check referenced by an alert policy. The operator must first remove or retarget the dependent policy, so provide that ordering (or automate it) before instructing them to delete and recreate the check.
Useful? React with 👍 / 👎.
…rrupted-stream rule Review revision of #21455 round 1: - Prometheus CPU limit back to "2": load is sustained 1.5-2.2 cores over 14h (the ~2.9-core spikes were kubelet scrape-timeout artifacts), 0% CFS-throttled, and the Prometheus-backed rules already time out - the 1600m cap would throttle them and the adapter's HPA metrics further. Starvation is fixed with requests plus the pool resize runbook instead. - Loki read path (ingester/querier 50m/256Mi, index-gateway/ruler 20m/128Mi) gets requests, arithmetic in the values file: jzv7 1913m of 1930m allocatable, mczx 1488m. loki values normalized CRLF->LF (file untouched since #2708; the hygiene check rejects new CRLF lines). - README: rollback now records the pre-apply helm revision (rolling back to rev 14 would revert #21306/#21389/#21358/#21409; #21389 is screenshots-off, the 10-13 502 fix); corrected the "renders with no diff" claim; added the 4-vCPU pool resize runbook (exact gcloud create + cordon/drain, zonal us-central1-a so the Grafana/Prometheus PVCs reattach); stack applies marked off-peak (Prometheus WAL replay of ~700k-980k head series freezes the pusher/listen/parakeet/VAD/diarizer HPAs; #21448's inert diarizer scrape job rides along); the 109/286 down-target count (34 stale kubelet endpoints) noted as operator crash-loop fallout expected to clear. - New metric rule omi-listen-audio-decode-failures shadows the paused corrupted-stream log rule on omi_listen_audio_decode_failures_total (startup zero-init children added); listen-429, ASGI-handshake and direct-OpenAI-quota gaps tracked in #21461.
…g-node CPU (#21455) * fix(monitoring): hold raw-line Loki alert rules and reserve monitoring-node CPU 2026-10-14 prod: Grafana /api/health flapped 502, alert evaluation logged 190 failures + 120 dropped ticks over 20 minutes, the prometheus operator restarted 48x and the adapter 35x in 31h, and every pusher deploy failed on alert provisioning. Two causes, both read-verified against prod: 1. Four committed alert rules query the Loki datasource for raw log lines (whole-namespace regex scans, 60s ticks, one with [$__auto]). They caused 340 of 410 rule-eval failures in 3h (196 from afd0krbk1bugwf alone), each timing out past the 30s datasource budget - the same failure class as the 2026-10-13 Cloud Logging rule (#21390). Pause all four and hold them in metric-inventory admission_holds; re-admit only on bounded counters. 2. Grafana, the operator and the adapter ran BestEffort on a ~1.93 allocatable-core monitoring node while Prometheus's 2-CPU limit exceeded total node capacity, so Prometheus bursts starved kubelet probes (the operator/adapter restart mechanism - SIGTERM after probe timeout) and Grafana's HTTP server. Cap Prometheus at 1600m and give Grafana, the operator and the adapter explicit requests. New contract test rejects any unpaused rule referencing a log datasource (type or prod Loki UID); README documents the policy. The 2-vCPU monitoring node pool remains undersized for 592k head series - resizing it is the follow-up (owner: infra). * fix(monitoring): Loki read-path requests, metric shadow for paused corrupted-stream rule Review revision of #21455 round 1: - Prometheus CPU limit back to "2": load is sustained 1.5-2.2 cores over 14h (the ~2.9-core spikes were kubelet scrape-timeout artifacts), 0% CFS-throttled, and the Prometheus-backed rules already time out - the 1600m cap would throttle them and the adapter's HPA metrics further. Starvation is fixed with requests plus the pool resize runbook instead. - Loki read path (ingester/querier 50m/256Mi, index-gateway/ruler 20m/128Mi) gets requests, arithmetic in the values file: jzv7 1913m of 1930m allocatable, mczx 1488m. loki values normalized CRLF->LF (file untouched since #2708; the hygiene check rejects new CRLF lines). - README: rollback now records the pre-apply helm revision (rolling back to rev 14 would revert #21306/#21389/#21358/#21409; #21389 is screenshots-off, the 10-13 502 fix); corrected the "renders with no diff" claim; added the 4-vCPU pool resize runbook (exact gcloud create + cordon/drain, zonal us-central1-a so the Grafana/Prometheus PVCs reattach); stack applies marked off-peak (Prometheus WAL replay of ~700k-980k head series freezes the pusher/listen/parakeet/VAD/diarizer HPAs; #21448's inert diarizer scrape job rides along); the 109/286 down-target count (34 stale kubelet endpoints) noted as operator crash-loop fallout expected to clear. - New metric rule omi-listen-audio-decode-failures shadows the paused corrupted-stream log rule on omi_listen_audio_decode_failures_total (startup zero-init children added); listen-429, ASGI-handshake and direct-OpenAI-quota gaps tracked in #21461.
Why
Prod Grafana is the alerting plane for every
alerts/*.jsonrule, and it runs on the default SQLite store.grafana.inihas no[database]section; the DB lives on a 20Gistandard-rwoPVC.On 2026-10-12, measured read-only via ro-prod, it logged two bursts of
database is locked: 11 lines at 03:02Z and 67 at 09:02Z. During the burst:Tick dropped because alert rule evaluation is too slowFailed to apply Alertmanager config for org … failed to list alert rules … database is lockedFailed getting data source … database is lockedUnable to sync admin configurationSo alert evaluation and notification are unreliable for minutes at a time, and nothing outside Grafana notices, because Grafana cannot alert on its own outage.
What changes
SQLite contention mitigation (prod and dev values, Grafana 12.1.0). Adds
[database] wal = true,query_retries = 10andtransaction_retries = 10.conf/defaults.iniandpkg/services/sqlstore/database_config.go. The defaults are false / 0 / 5.grafana.db-wal/-shmbesidegrafana.dbon the same RWO mount, which is fine for this single-pod deployment.External dead-man for Grafana itself.
https://monitor.omi.me/api/health: 60 s period, from USA/EUROPE/ASIA_PACIFIC.ALIGN_NEXT_OLDER+REDUCE_COUNT_FALSEgrouped bycheck_id,> 1), so one region's network blip doesn't page.backend/deploy/monitoring/grafana-deadman.jsonand reconciled idempotently by.github/scripts/ensure_grafana_deadman.py.Workflow.
gcp_cloud_run_metrics_egress.yml(prod dispatch only):MONITORING_DEADMAN_NOTIFICATION_CHANNELSis unset;This is a new variable; the misnamed
SYNC_BACKFILL_ALERT_NOTIFICATION_CHANNELSis not reused.Before / after merge (operator)
MONITORING_DEADMAN_NOTIFICATION_CHANNELS(comma-separated full channel resource names).[email protected]has Monitoring uptime-check and alert-policy write permission.workflow_dispatchgcp_cloud_run_metrics_egress.ymlonmainwithenvironment=prod. This needs environment approval.Verification
Ensure-script tests (dead-man + generic policy + route-5xx): 59 passed.
Monitoring suites through
backend/test.sh: 115 passed.make preflight: 40 checks. YAML parses;actionlintis clean; no cached chart was available forhelm template.Independent review (Cursor Grok) found two defects, both fixed in
ff1195e044b:The review confirmed the 12.1 option names/types, the WAL file placement, the prod-only fail-closed gate, and the prod identity on the ensure step.
Product invariants affected
.github/workflows/gcp_cloud_run_metrics_egress.ymlmatches thegcp_*.ymlglob. The change adds a prod-only Cloud Monitoring uptime check + alert policy formonitor.omi.me(Grafana) and a fail-closed variable check. It does not change any artifact's serving authority, Firebase/Firestore project, or release-pipeline routing.Failure-Class: FC-alert-never-provably-fired
🤖 Generated with Claude Code