Repository navigation
fix(monitoring): hold raw-line Loki alert rules and reserve monitoring-node CPU - #21455
Conversation
…g-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).
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: 62fe7ad004
ℹ️ 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".
| # SIGTERM-killed by its own liveness probe 48 times in 31h whenever Prometheus | ||
| # bursts consumed the node. Requests buy it a guaranteed share (measured use: | ||
| # 2-25m CPU, 25Mi). Probe timeout stays at the chart default. | ||
| operator: |
There was a problem hiding this comment.
Move operator resources under prometheusOperator
The kube-prometheus-stack chart renders operator resources from .Values.prometheusOperator.resources (see the vendored template at backend/charts/deepgram-self-hosted/nova-3/charts/kube-prometheus-stack/templates/prometheus-operator/deployment.yaml:157-158), so this unknown top-level operator block is ignored during the workflow's Helm upgrade. Consequently, the operator remains BestEffort and retains the probe-starvation/restart failure this change is intended to fix; rename this key to prometheusOperator.
Useful? React with 👍 / 👎.
| # Referenced here so a rule that names the datasource only by UID cannot slip | ||
| # past the type check below. | ||
| LOG_DATASOURCE_UIDS = {"aet29e27cgmwwc"} | ||
| LOG_DATASOURCE_TYPES = {"loki", "cloudlogging"} |
There was a problem hiding this comment.
Recognize the actual Cloud Logging datasource type
Grafana exports the Cloud Logging plugin as googlecloud-logging-datasource, not cloudlogging; for example, the currently unpaused omi-cr-start-fail rule uses that exact type and UID deuxlwt1d569sb in alerts/backend.json. This test therefore passes while a live rule still scans raw Cloud Logging lines, and future rules using the same datasource also evade the incident-prevention guard. Include the exported type and/or the production Cloud Logging datasource UID.
Useful? React with 👍 / 👎.
| 1 CPU / 2Gi memory requests, 1600m CPU / 8Gi memory limits, and a 100Gi | ||
| `standard-rwo` claim. The CPU limit sits below the monitoring node's ~1930m | ||
| allocatable so Prometheus bursts cannot starve the kubelet probes, Grafana and | ||
| the operator on the same node (2026-10-14: 48 operator and 35 adapter | ||
| liveness-probe restarts in 31h, Grafana `/api/health` 502s); Grafana and the |
There was a problem hiding this comment.
Update the preflight's expected production diff
This section now documents intentional Grafana resource and Prometheus CPU changes, but the same production procedure still says at lines 1044-1049 that rendering these values against revision 14 must produce an empty diff and that a Helm revision should not be created otherwise. An operator following the runbook for this incident will necessarily see the resource changes and receive contradictory guidance about applying them; update the expected-diff text to enumerate the intended manifests or compare against the new post-rollout baseline.
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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4aa051a97
ℹ️ 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".
| "id": 86, | ||
| "uid": "omi-listen-audio-decode-failures", |
There was a problem hiding this comment.
Add the replacement rule to the Grafana import path
When this change is rolled out through the documented production workflow, this replacement remains repository-only: gcp_cloud_run_metrics_egress.yml invokes verify_pusher_live_alert_route.py --mode import, but that importer reads alerts/live-stt.json and its LIVE_STT_IMPORT_UIDS does not contain this UID; the subsequent fleet check only fails for gated rules. Because Helm does not provision Grafana alerts and production is the live source, pausing df2a40h2fbjswe as prescribed leaves corrupted-audio failures without the claimed live replacement unless this UID is added to an import path or explicitly created through the provisioning API.
Useful? React with 👍 / 👎.
| queryFrontend: | ||
| replicas: 2 | ||
| maxUnavailable: 1 | ||
| nodeSelector: | ||
| <<: *nodeSelector |
There was a problem hiding this comment.
Reserve CPU for the complete Loki read path
Under the CPU-saturation scenario this change is intended to fix, the two queryFrontend pods remain without resource requests, as do the configured queryScheduler pods immediately below them. In distributed Loki, every query is received by the query frontend and passed through the scheduler before a querier executes it, so these BestEffort stages can still be starved even though the downstream queriers and index gateways are now Burstable (Grafana Loki read-path documentation). Add requests for both components so the reservation actually covers the end-to-end query path.
Useful? React with 👍 / 👎.
…Operator key (#21468) #21455 used a top-level operator: key, which kube-prometheus-stack ignores, so prod kept the operator BestEffort. Rename the key and guard top-level keys. Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Stabilizes prod Grafana alert evaluation (2026-10-14 incident:
/api/health502s, 190Failed to evaluate rule+ 120 dropped ticks in 20 min, operator 48 restarts / adapter 35 in 31h, every pusher deploy failing on alert provisioning). Revised per review of round 1: the Prometheus CPU cap is back at 2 — the starvation fix is requests plus the node-pool resize runbook.1. Raw-line Loki alert rules (the #21390 failure class, again)
Four committed rules query the Loki datasource for raw log lines on a 60s tick — one scans the whole
prod-omi-backendnamespace with a regex (afd0krbk1bugwf, 196 of 410 rule-eval failures in 3h), another uses the unbounded[$__auto]range. Each evaluation blew the 30s datasource timeout, retried, and dropped ticks:afd0krbk1bugwfOpenAI - Quota Exceededfewwk2goqfklcfBackend - API Quota Exceeded (429)devzd05c0bocgcTranscription Service Error Ratedf2a40h2fbjsweTS Error Rate: Data corruptedFix: pause all four (split files + combined export kept byte-equal) and record
admission_holdsinmetric-inventory.prod.json. Re-admission requires a bounded counter, never a log datasource.Coverage after pausing:
omi-listen-audio-decode-failuresreadsomi_listen_audio_decode_failures_total(backend-listen scrape job; children zero-initialized at startup inutils/metrics.pyso family absence is unambiguous).omi-llm-gateway-lane-failure-ratio,omi-llm-gateway-lane-zero-success, fallback rate) —llm_gateway_requests_totalcarriesoutcome/error_class/upstream_http_status.2. Monitoring-node CPU: requests, not a lower Prometheus cap
The Prometheus CPU limit stays 2 (review): load is sustained at 1.5–2.2 cores across 14h with the node pinned near its 1930m allocatable — the ~2.9-core readings were an artifact of kubelet scrapes timing out mid-sample — and Prometheus is 0% CFS-throttled. The Prometheus-backed rules (
omi-stt-fallback-leg-dead34×,omi-stt-leg-lifecycle-gap21×) already time out; a lower cap would throttle them further and stall the adapter's custom-metrics reads behind every HPA. Shipped instead:Requests arithmetic (two pool nodes, 1930m allocatable each; live listing 2026-10-14, nominal replica spread):
The durable fix is the 4-vCPU pool resize runbook now in the monitoring README:
gcloud container node-pools create monitoring-pool-v2(e2-highmem-4, zonalus-central1-aso the Grafana/Prometheusstandard-rwoPVCs reattach, labelsenv=prod,service=monitoring, no taints to replicate), then cordon + drain the old pool. Not run here — owner: lead.Regression guards
test_live_alert_rules_never_query_log_datasourcesrejects any unpaused rule referencing a log datasource (type or prod Loki UID).test_corrupted_stream_log_rule_stays_shadowed_by_the_decode_failures_counter— the paused corrupted-stream log rule must keep its metric shadow; removing one requires deciding both.test_monitoring_stt_metric_zero_init).Failure-Class: new
Line-Count-Exception: backend/utils/metrics.py | 1540 -> 1556 | zero-init the 54 bounded omi_listen_audio_decode_failures_total children (codec x client_platform) so the new omi-listen-audio-decode-failures alert has an unambiguous family baseline per the startup-exposition contract
Apply steps (owner: lead — no prod mutations in this PR) — apply off-peak
helm history prod-omi-kube-prometheus-stack -n prod-omi-monitoring --kube-context gke_based-hardware_us-central1_prod-omi-gke→ note the highest deployed revision (<pre-apply-revision>below).alert-rules/{uid}— GET the full rule, setisPaused: true, PUT the whole body back (withX-Disable-Provenance), checking the HTTP status per uid so a 404/405 cannot look like success:Deploy Cloud Run Metrics Egress(gcp_cloud_run_metrics_egress.yml) onmainwithenvironment=prod(requires prod Environment approval). Off-peak because the Prometheus pod restarts and replays its WAL (~700k–980k head series): during replay the adapter serves stale custom metrics and the pusher/listen/parakeet/VAD/diarizer HPAs freeze. The rollout also carries Make batch diarizer installation isolated, observable and image-qualified #21448'sdiarizer-batch-metricsscrape job + adapter rule, which are inert (no batch pods exist yet).helm upgrade --install prod-omi-loki grafana/loki -f loki/prod_omi_loki_values.yaml, prod context/namespace).helm upgrade ... --atomic --wait --timeout 10m.Rollback
.isPaused = false(not recommended — it recreates the outage).helm rollback prod-omi-kube-prometheus-stack <pre-apply-revision> -n prod-omi-monitoring --kube-context gke_based-hardware_us-central1_prod-omi-gke --wait --timeout 10m— never a hard-coded revision. Rolling back to the 2026-10-14 revision 14 would also revert fix(monitoring): Grafana SQLite WAL + lock retries, external Grafana dead-man #21306, fix(monitoring): stop alert screenshots that stall Grafana #21389 (screenshots back ON — recreates the 10-13 502s), perf(monitoring): trim unused kubelet series and successful probe logs #21358 and fix(monitoring): rename custom-metric API aggregates back to their plain omi_ names #21409, all live in prod.helm rollbackto their recorded pre-apply revisions the same way.Verify
https://monitor.omi.me/api/health: 10 consecutive 200s at 30s spacing.Failed to evaluate rule= 0,Tick dropped= 0.gcp_backend_pusher.yml) passes Grafana alert provisioning + post-rollout reverify.sum(omi_listen_audio_decode_failures_total)returns the zero-initialized series.Evidence commands (read-only)
kubectl --context gke_based-hardware_us-central1_prod-omi-gke -n prod-omi-monitoring logs <grafana-pod> -c grafana --since=3h(failure counts by rule_uid),kubectl get events --field-selector involvedObject.name=<operator-pod>,kubectl top nodes, Prometheusprometheus_tsdb_head_series,max_over_time(scrape_duration_seconds[3h]),count(up==0)/count(up).