Guides · Slack anomaly alerts Real-time anomaly alerts in Slack from Postgres or MySQL.
Catch payment or signup drops minutes after they start—tested on 8 weeks of SQL history.
Works read-only on Postgres, MySQL 8+, RDS, Aurora and Supabase · Zero cron jobs to host
# ops-alerts · Thu 14:05 · MySQL prod-replica
Quill APP · 14:05
# ops-alerts · Thread · Thu 14:07
Kabir 14:06
@Quill split the UPI failures by gateway error code in the last 2 hours.
Quill APP · 14:07
27 of 31 failed UPI attempts returned GATEWAY_TIMEOUT from Razorpay starting at 13:18. Cashfree UPI success rate is steady at 94%.
1 read-only query · 0.35 s · SQL attached in Numling
# ops-alerts · Thread · Thu 15:05
Quill APP · 15:05
The real problem
Fixed thresholds train your team to mute the channel.
Setting “alert if orders < 60/hour” fires every Sunday morning and every holiday. Comparing against the same hour on the same weekday over the last 8 weeks—and replaying the rule before turning it on—catches real drops without noise.
SAME METRIC (HOURLY PAID CHECKOUTS), 3 RULES, REPLAYED ON 8 WEEKS
Fires in 8 weeks · only 2 were real incidents (1 payment gateway outage, 1 broken deploy)
Describe what to watch in plain English
“Alert #ops-alerts if hourly paid checkouts drop more than 35% under a usual same-weekday hour, split by payment method.”
Replay it on your last 8 weeks before saving
Quill runs the query over your past 8 weeks and shows every timestamp it would have paged you—so you tighten the sensitivity before a single alert posts.
Receive the alert with the likely driver already split
Instead of “orders down 38%”, Quill breaks the drop down by gateway, city, channel or app version right inside the Slack post.
Investigate in thread, auto-resolve when recovered
Reply to @Quill in the same thread to pull exact error codes or affected order IDs. Once the next hour recovers, Quill closes the loop automatically.
Doing it by hand: copy-paste Postgres, MySQL 8+ & Slack webhook
Run either query on an hourly cron against a read-only replica. If it returns a row, post the JSON payload to a Slack Incoming Webhook.
with hourly as (
select
date_trunc('hour', created_at) as hr,
count(*) filter (where status = 'paid') as paid_orders
from orders
where created_at >= date_trunc('hour', now() - interval '1 hour') - interval '56 days'
group by 1
),
current_hr as (
select
date_trunc('hour', now() - interval '1 hour') as hr,
coalesce(
(select paid_orders from hourly where hr = date_trunc('hour', now() - interval '1 hour')),
0
) as paid_orders
),
baseline as (
select
percentile_cont(0.5) within group (order by h.paid_orders) as median_orders,
count(*) as sample_weeks
from hourly h
join current_hr c
on extract(dow from h.hr) = extract(dow from c.hr)
and extract(hour from h.hr) = extract(hour from c.hr)
and h.hr < c.hr
)
select
c.hr,
c.paid_orders,
round(b.median_orders::numeric, 1) as usual_orders,
round(((c.paid_orders - b.median_orders) / nullif(b.median_orders, 0))::numeric * 100, 1) as pct_diff
from current_hr c, baseline b
where b.sample_weeks >= 4
and c.paid_orders < b.median_orders * 0.65;WITH hourly AS (
SELECT
DATE_FORMAT(created_at, '%Y-%m-%d %H:00:00') AS hr,
DAYOFWEEK(created_at) AS dow,
HOUR(created_at) AS hod,
SUM(CASE WHEN status = 'paid' THEN 1 ELSE 0 END) AS paid_orders
FROM orders
WHERE created_at >= TIMESTAMP(DATE_FORMAT(NOW() - INTERVAL 1 HOUR, '%Y-%m-%d %H:00:00')) - INTERVAL 56 DAY
GROUP BY 1, 2, 3
),
curr AS (
SELECT
DATE_FORMAT(NOW() - INTERVAL 1 HOUR, '%Y-%m-%d %H:00:00') AS hr,
DAYOFWEEK(NOW() - INTERVAL 1 HOUR) AS dow,
HOUR(NOW() - INTERVAL 1 HOUR) AS hod,
COALESCE(
(SELECT paid_orders FROM hourly WHERE hr = DATE_FORMAT(NOW() - INTERVAL 1 HOUR, '%Y-%m-%d %H:00:00')),
0
) AS paid_orders
),
ranked AS (
SELECT
h.paid_orders,
ROW_NUMBER() OVER (ORDER BY h.paid_orders) AS rn,
COUNT(*) OVER () AS cnt
FROM hourly h
JOIN curr c ON h.dow = c.dow AND h.hod = c.hod AND h.hr < c.hr
),
baseline AS (
SELECT AVG(paid_orders) AS median_orders, MAX(cnt) AS sample_weeks
FROM ranked
WHERE rn IN (FLOOR((cnt + 1) / 2), CEIL((cnt + 1) / 2))
)
SELECT
c.hr,
c.paid_orders,
ROUND(b.median_orders, 1) AS usual_orders,
ROUND((c.paid_orders - b.median_orders) / NULLIF(b.median_orders, 0) * 100, 1) AS pct_diff
FROM curr c, baseline b
WHERE b.sample_weeks >= 4
AND c.paid_orders < b.median_orders * 0.65;{
"text": "Paid checkouts dropped 38% under a usual Thursday",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Paid checkouts dropped 38% under a usual Thursday (13:00–14:00)*\n53 paid orders vs usual 85 (8-week median)."
}
},
{
"type": "context",
"elements": [
{ "type": "mrkdwn", "text": "Source: MySQL prod-replica · 8-week same-weekday median" }
]
}
]
}FAQ
Questions about Slack anomaly alerts.
How fast can Slack anomaly alerts run on Postgres or MySQL?
Every 15 minutes, hourly, or daily—always inside a read-only session with a query timeout so monitoring never slows production.
Why compare against the same weekday instead of yesterday?
Startups have strong day-of-week swings: Mondays and weekends rarely look like Thursdays. Comparing Thursday 13:00–14:00 against the last 8 Thursdays cuts weekend and Monday false positives dramatically.
Can we run this on a read replica or behind a VPC?
Yes. Connect a read replica directly over TLS, allow Numling’s fixed IP, or connect through a forward-only SSH bastion.
What happens when the metric recovers?
Quill posts an auto-resolved update in the same Slack thread once the next window returns inside the normal band, so nobody chases an already-fixed issue.
Turn on 8-week-tested Slack alerts.
Connect Postgres, MySQL, MongoDB or Metabase read-only in ten minutes.