Alert on SQL Culprits and Deploy Regressions, Not 40 Blocked Victims
Why standard wait and session alerts page on-call for victims instead of root causes, and how Culprit's pluggable notifier sends one auto-resolving PagerDuty, Slack, or Teams alert with the culprit SQL.
If you have ever been on database on-call, you know the 3 AM alert storm: PagerDuty fires for API checkout latency, then fires for 38 blocked sessions on orders-prod, then fires for connection pool exhaustion. Every single alert names INSERT INTO dbo.order_items, which usually runs in 1.2 ms.
INSERT INTO dbo.order_items is innocent. It is sitting at the back of a lock queue behind SPID 61, where a background job ran UPDATE dbo.orders inside BEGIN TRAN, hit a slow webhook retry in Python, and left the transaction sitting idle in transaction for four minutes.
Paging an engineer with 40 victim queries wastes the first fifteen minutes of an outage just walking blocking_session_id pointers by hand. And as we saw when comparing Microsoft Database Hub vs. Culprit + ADX, gating basic alert rules behind paid Fabric Data Activator CUs adds insult to injury.
Collapse 40 victims into 1 culprit before the alert fires
In Culprit’s collector pipeline, blocking chains, metadata-lock sandwiches (LCK_M_SCH_M queued behind a long reader while blocking every new LCK_M_SCH_S caller), deadlocks, memory-grant starvation, and plan flips are reduced to single root-cause episodes in CulpritIncidentsV1 and CulpritChangesV1.
Take deadlocks. Instead of alerting “Deadlock count > 0” and leaving you to hunt down .xel files or ring buffers, the collector parses the deadlock XML (or PostgreSQL log / MySQL INNODB STATUS), redacts SQL literals, and records both the killed victim and the surviving lock holder:
Hover either session node above: the incident record already knows that stripe-webhook-worker (SPID 88) and invoice-reconciler (SPID 134) acquired PK_subscriptions and IX_ledger_sub_period in opposite order, which statement lost, and how to reorder the transaction.
Three warehouse alert streams (plus collector health)
When you run culprit collect queries --config archive.json --name Prod, Culprit generates four distinct query helpers for ADX or ClickHouse so different classes of problems route cleanly:
| Generated Helper | What triggers it | Typical routing |
|---|---|---|
ProdRecordedIncidentAlertsDuring | Active/resolved episodes in CulpritIncidentsV1 (blocking chains, deadlocks, PAGELATCH_EX, THREADPOOL, memory grants) | PagerDuty + #db-incidents Slack |
ProdNewRegressionsDuring | CulpritChangesV1 queries that got slower or switched plans past impact threshold (enriched with culprit mark deploy timestamps) | #eng-releases Slack / Teams |
ProdNewHighFindingsDuring | Newly observed high-severity actionable findings in CulpritFindingsV1 (e.g. log-reuse-blocked, XID wraparound, missing index) | GitHub Issues / #db-tuning |
ProdStatusNow / ProdStatus | Stale collector heartbeats, revoked VIEW DATABASE PERFORMANCE STATE, or incomplete reads | Platform / infra ops channel |
If your team already triggers DRI pages from Azure Monitor Scheduled Query Rules (over ADX) or Grafana Alerting (over ClickHouse), you can call those helpers directly without running a separate alert binary:
// ADX DRI alert query (deduplicate by TargetId, OriginalScopeId, OriginalSource, EpisodeId, ControllerVersion)
ProdRecordedIncidentAlertsDuring("billing-prod", ago(5m), now())
| project FirstRecordedObservation, TargetId, OriginalScopeId, OriginalSource, EpisodeId, ControllerVersion, Mechanism, VictimSummary, DeveloperAction
-- ClickHouse DRI alert query (+ pair with ProdStatusNow for collector staleness)
SELECT FirstRecordedObservation, TargetId, OriginalScopeId, OriginalSource, EpisodeId, ControllerVersion, Mechanism, DeveloperAction, 1 AS AlertValue
FROM ProdRecordedIncidentAlertsDuring(resource = 'billing-prod', window_from = now64(9, 'UTC') - INTERVAL 5 MINUTE, window_until = now64(9, 'UTC'));
For the full list of automatic wait/DMV investigations, all 18 *V1 warehouse tables, and the ProdStatusNow dead-collector query, see 24/7 SQL Root-Cause Investigations, Warehouse Tables, and DRI Alerts.
Pluggable culprit-notify without bloated SDKs or duplicate pages
To deliver those alerts without Fabric Activator or Grafana Enterprise, we built culprit-notify around a pure state machine (AlertEvaluator) and five tiny channel crates (slack, teams, pagerduty, webhook, github-issues).
Why does that five-part deduplication key matter?
In real collectors, an active blocking episode emits new revisions as wait time grows, or you might upgrade Culprit’s rules_version and backfill historical warehouse captures. Because AlertEvaluator tracks (TargetId, OriginalScopeId, OriginalSource, EpisodeId, ControllerVersion) anchored to FirstRecordedObservation (stored atomically on disk or via conditional ETag in Blob/S3), a long-running incident never re-pages on revision updates, backfills older than your novelty window stay silent, and PagerDuty auto-resolves the exact dedup_key the moment the blocker clears.
Validate your routing config offline (verifying HTTPS origins and secret references without opening sockets), then evaluate batches on a cron or Kubernetes job:
culprit collect notify validate --config /etc/culprit/notify.json
culprit collect notify evaluate --config /etc/culprit/notify.json --input alerts-batch.json
If your org uses an internal incident bus, Opsgenie, or Jira, culprit-notify-webhook signs every JSON payload with X-Culprit-Signature-256 (HMAC-SHA256), or you can register a custom Rust NotificationSink in twenty lines via NotifierBuilder::with_sink.
Include a deep link to culprit-archive-web in the Slack/Teams template, or wire the webhook into culprit agent triage-warehouse so regressions automatically draft a lint-sql-verified fix PR.
Dropping an index that a read replica relies on or indexing a 40%-selective column makes production slower. Seven anti-false-flag rules we hardcoded into Culprit's Rust check pipeline so alerts stay trustworthy.