Monitor User Guide
1. Executive Summary
The Monitor module (aegis-monitor) is the always-on health check for every
active route. It answers two questions on a schedule: is the page up? and does
the page still look right?
Note for anyone reading older docs or decks: there used to be a separate
visual-monitorworker. It was removed from the repo (commit24af897) and its job now lives here. Monitor holds the Browser Rendering binding, the screenshot bucket, and all the drift logic. There is one monitor, not two.
2. What runs, and when
Monitor is driven by two cron triggers:
| Cron | What it does |
|---|---|
15 * * * * (hourly) |
Uptime + content pass across active routes. Screenshots are skipped by design. |
30 3 * * * (daily) |
Retention cleanup — purges visual_audits rows older than 30 days and their R2 screenshots. |
Visual capture is the expensive part, which is why the hourly pass skips it. A single route can be re-shot on demand (see §5) without waiting for a full pass.
Which pages: every active page with Monitor this page ticked (the page's wizard, QA & Monitor step; on for every page by default). Untick it and the page is left out of the rotation and every sweep; QA is separate (QA this page). A check you start by hand on one page still runs.
3. Uptime and content checks
Endpoint pinging: fires real HTTP requests at live landing pages and critical endpoints, following the route's configured origin.
Status verification: confirms routes return
200, not a500or an unintended404.Latency tracking: flags backend origins (Lovable SPAs, Shopify) that are degrading.
Request pacing: requests are deliberately paced. Firing a full sweep flat out triggered Cloudflare rate limiting and produced
429false positives, so the sweep is throttled rather than parallelised.Refused pages come back. Shopify's bot scoring still refuses a share of checks (
429). A refused check shows grey in Recent checks ("not checked"), never red, and does not count as a check: the page goes back in the rotation about 10 minutes later, ahead of pages checked fine, instead of a whole lap later. Settings → QA & Monitor → Monitor → Minutes between checks slows the rotation on save (3, 4, 10 …); faster than every 2 minutes needs a deploy.A refusal is "busy" for the whole store. Shopify asks for a ten-minute back-off after one (Shopify Plus Support, 2026-10-15), so Monitor doesn't retry a refused page, and no page of that store is checked for 10 minutes; the other store and non-Shopify pages carry on. The Monitor card says UK store busy (Shopify 429) · its checks resume HH:MM meanwhile.
Where pages are fetched from. Each page type chooses, in Settings → Pages → Page Types → Edit → Monitor → Monitor fetches pages from:
- Cloudflare (the default): the monitor fetches the page itself.
- Hetzner node: the page is fetched through a small service on our Hetzner server instead.
The type decides for every page of it, with no exceptions, and a change applies on each page's next check. The Page Types list shows via Hetzner under the type's checks. From Cloudflare, Shopify refused 50–72% of checks. From the Hetzner node it refused none of 150. On Hetzner, if that service can't be reached, the check fails and says so; it never quietly goes back to Cloudflare. Every check records which path it took: the Monitor's recent checks show via Hetzner under the time it took, and a refusal's tooltip says it too (
via=).What counts as a refusal. A
429, a430(Shopify's "request blocked"), or a Cloudflare challenge: acf-mitigatedheader, or a403or503whose page is a challenge. All of them show grey and pause the store. A plain503is not a refusal. It means the store is down, so it shows red as a failure, because an outage is what Monitor is for.Idle is green. With nothing due (every page checked in the last hour, or the only pages due on a store in its 429 back-off) the heart stays green and says idle. Once a page is due, the heart counts from when it became due: amber, then red, only if it isn't checked.
A refused check says why. Its tooltip reads
refused:followed by what Shopify sent back (Retry-After, cf-ray, any call-limit header) andbot-auth=, whether the request carried the crawler signature, andshape=, its form: which parts it has, its lengths, days to expiry, andsigid=, a short hash of the Signature value that tells the UK and US signatures apart (each store needs its own) without showing it.The crawler signature. Monitor fetches Shopify pages with the store's Web Bot Auth signature, so Shopify knows the request is the merchant's own monitor rather than a bot. To create one, in each store's Shopify admin: Online Store → Preferences → Crawler access → Create signature, for up to 3 months. Each of its three values goes in its own Secrets Store secret:
web-bot-auth-uk-signature-input,web-bot-auth-uk-signatureandweb-bot-auth-uk-signature-agent(-us-for the US store). Two weeks before it expires, Monitor posts Crawler signature expiring to Slack once a day. A signature can't be renewed: create a new one and replace the secret.Each page at most once an hour. A page that had a real check in the last hour is not due, so Monitor asks Shopify less; a rate-limited check does not count, so a refused page stays due. When no page is due the rotation waits, and the Monitor card says Every page checked in the last hour · next due HH:MM.
Against the PIM: Clones only. With each check of a Clone's page, Monitor asks admin to compare what was published with the PIM, when Check against PIM is ticked on the Clone and its page type. A change fails the check ("PIM changed: Price"), even on a check Shopify refused, and PIM shows under checked for. Live stores only: a difference on a staging copy neither counts, nor shows PIM changed on the Clone, nor tells Slack. Other page types are not checked against the PIM: their product data is not reliably in it, and a future upgrade will check them another way.
4. Visual drift detection
Monitor renders each page in a real headless browser (Cloudflare Browser Rendering), screenshots it, and compares it against a stored baseline.
- Baselines live in
route_visual_baselines; captures and diffs live in R2 (SCREENSHOTS_BUCKET) with rows invisual_audits. - Rolling baseline: on a clean capture (≤ 0.5% drift) the fresh screenshot is promoted to the baseline. This matters — without it, run-to-run rendering noise accumulates until it trips the threshold and reports drift that isn't real. On genuine drift the last-good baseline is kept until a human reviews it.
- Ignore selectors: dynamic overlays are hidden before capture, via a global
list (
GLOBAL_IGNORE_SELECTORS) and a per-route list, both in Settings → QA & Monitor → Monitor (Global list and Per-page; Add selector opens a modal and saves at once). The default global entry targets the Market-Distributor localisation popup ("We don't ship to …"), which only appears in the headless geo context and would otherwise register as drift on every run. - DOM hashing: a DOM hash is stored alongside the screenshot so structural changes can be distinguished from purely visual ones.
Reading an audit report
/api/report/:audit_id shows Baseline, Current and Diff side by side. If the
change is legitimate, Image OK promotes the current capture to the baseline in
one click. Report images are readable without a session so the links work
straight from Slack.
5. On-demand checks
GET /api/trigger runs a pass immediately. Useful parameters:
route_id— check a single route instead of everything.force_hourly— run the hourly configuration on demand.force_visual— capture screenshots even under the hourly config, which normally skips them. This is what the per-route "Run Visual Check" action in the Admin dashboard uses to re-shoot and re-baseline one route.force_slack— send the Slack report even if the run would normally be quiet.
The endpoint is behind Basic Auth. Credentials are validated against the users
table, then ADMIN_PASSWORD, then — if that isn't set — any value present in the
app_tokens table.
6. Incident alerting
- Failures are only escalated after consecutive misses, to rule out momentary network blips.
- Alerts go to Slack with the URL, the status code, and the time of failure; drift alerts include links to the three-image report.
- Alert links point at
aegis.purdyandfigg.dev.
7. Data retention
Monitor is the only module with a full retention story, and it's worth knowing what it does and doesn't cover:
| Table | Retention | Owner |
|---|---|---|
visual_audits + R2 screenshots |
30 days | Monitor daily cron |
route_logs |
48 hours | Monitor |
qabot_test_runs |
72 hours | Admin daily cron |
analytics_logs |
365 days | Admin daily cron |
click_events |
365 days | Admin daily cron |
The screenshot cleanup is reference-safe: it never deletes an object still referenced by a retained audit row or by an active baseline.
Analytics retention used to run inside the Analytics worker's queue consumer, on every batch. It now runs once a day from the Admin cron and is indexed. The window is 365 days rather than 90 on purpose: there is no archive behind the purge yet, so anything it deletes is gone once D1's 30-day Time Travel passes. Shorten it once day-partitioned exports are landing in R2.