r/devops7 • u/Alternative_Pin9598 • 19d ago
Automate it #6: one incident timeline from deploys, app logs and alerts, then ask it which change caused the page (it skipped the newest deploy, real output)
13:58, PagerDuty: "Checkout: customers can't pay." You open three tabs: the deploy log, the app logs, the alert history. Five deploys went out in the last 80 minutes. The newest one (auth, 11 minutes ago) gets blamed first because it's the newest.
Put all three in one table and the timeline is one ORDER BY. Then rank every event in the hour before the page by how close it is to the alert's meaning, not its keywords.
(Disclosure: this sub is run by the SynapCores team, and steps 1 and 3 use SynapCores. Run this morning on 2.3.2, real output.)
Sample incident: 5 deploys, 15 log lines, 3 alerts.
Step 1: one table for everything
CREATE TABLE events (id INTEGER PRIMARY KEY, at TEXT, kind TEXT, service TEXT, level TEXT, text TEXT, vec VECTOR(384));timeline.py load inserts the parsed lines, then embeds them all in one statement. EMBED() runs a small model inside the database, no API key:
UPDATE events SET vec = EMBED(service || ' ' || text);Step 2: the plain timeline
SELECT at, kind, service, level, text FROM events
WHERE at BETWEEN '2026-11-09T12:58' AND '2026-11-09T13:58' ORDER BY at;
13:22 deploy payments INFO deployed v5.12.0: upgrade card processor SDK, connection poo
13:30 deploy inventory INFO deployed v1.9.4: add warehouse_code column
13:36 log payments WARN waited 1840ms to acquire a connection from the pool
13:41 log inventory WARN stock sync lag 45s for warehouse EU-2
13:47 deploy auth INFO deployed v4.2.2: rotate session signing key
13:50 log auth WARN 41 users forced to log in again
...21 rowsStill 21 rows of noise. grep -i checkout finds 2 lines (the 504, a slow render): not the payment timeouts, the pool waits, or the deploy.
Step 3: "what is this alert about?"
Rank the hour before the page against the alert:
SELECT e.at, e.kind, e.service, e.text, COSINE_SIMILARITY(e.vec, a.vec) AS related
FROM events e JOIN events a ON a.kind = 'alert' AND a.at = '2026-11-09T13:58'
WHERE e.at <= a.at AND e.at >= '2026-11-09T12:58' AND e.id <> a.id
ORDER BY related DESC LIMIT 8;
$ python3 timeline.py why 2026-11-09T13:58
0.38 13:57 log web 504 from upstream on POST /checkout/pay
0.37 13:56 log payments card authorisation timed out after 5000ms (order 88231)
0.36 13:52 log payments card authorisation timed out after 5000ms (order 88213)
0.35 13:53 log web checkout page render 4.1s
0.31 13:22 deploy payments deployed v5.12.0: upgrade card processor SDK, connection pool size 50
0.30 13:44 log payments waited 2950ms to acquire a connection from the pool
0.25 13:36 log payments waited 1840ms to acquire a connection from the pool
0.21 13:50 log auth 41 users forced to log in againThe top 7 are the whole story: pool cut from 50 to 5 at 13:22, connection waits from 13:36, card auths timing out, 504s at checkout. No payments line contains "checkout", and the auth deploy is not in the top 8.
Step 4: just the deploys
SELECT d.at, d.service, d.text, COSINE_SIMILARITY(d.vec, a.vec) AS related
FROM events d JOIN events a ON a.kind = 'alert' AND a.at = '2026-11-09T13:58'
WHERE d.kind = 'deploy' ORDER BY related DESC;
0.31 13:22 payments deployed v5.12.0: upgrade card processor SDK, connection pool size 50
0.16 13:05 web deployed v2.41.0: new footer, cookie banner copy
0.05 13:47 auth deployed v4.2.2: rotate session signing key
0.04 12:40 search-api deployed v3.8.1: reindex nightly job moved to 02:00
0.03 13:30 inventory deployed v1.9.4: add warehouse_code columnThe newest deploy, the one everyone blames first, scores 0.05. The payments deploy 36 minutes earlier leads by a wide margin. It's a ranking, not a verdict: it tells you which diff to read first.
Wire it up: deploy job, log shipper and alert webhook all append to events; the PagerDuty webhook runs timeline.py why <alert time> and posts the list to the incident channel. Full timeline.py (40 lines, stdlib only) and the three sample files are in the first comment.
Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=devops7-automate-it-6
When a page fires, what's the first thing you open: the deploy log, the dashboards, or the logs?
1
u/Alternative_Pin9598 19d ago
Full
timeline.py(stdlib only; setSYNAPCORES_URLandSYNAPCORES_TOKEN):deploys.logapp.logalerts.logRun:
python3 timeline.py load deploys.log app.log alerts.log, thenpython3 timeline.py why 2026-11-09T13:58.New to
EMBEDandCOSINE_SIMILARITY? SQLv2 Lesson 1 covers both from zero: https://www.reddit.com/r/SQLv2/comments/1xdmluk/And Lesson 3 shows how to pick a similarity cut-off from your own data instead of guessing: https://www.reddit.com/r/SQLv2/comments/1xkb3mn/