Order Pipeline Health Monitoring
REF-6065 · Order Failure Detection & Monitoring
The Problem
There is no mechanism to detect orders that are stuck, lost, or failing at any pipeline stage. The team manually checks every Mirakl instance daily — a process that doesn't scale with SFB expansion, Middle East, and Reiss coming online. Recent incidents where Noatum and GWW didn't receive orders were discovered days later. REF-3442 attempted a "Marketplace Order Error Tracking System" but was canceled.
Pipeline Stages to Monitor
The order pipeline has 4 stages, each with different failure modes. This project focuses on stages 1–3. Stage 4 (dispatch/delivery) is already covered by REF-6062.
Stage 1: Marketplace → order_source (Ingest)
What to check
Are orders arriving from each marketplace? Compare expected order volume against actual. Query order_source table.
Failure modes
- Marketplace API down
- Authentication expired
- Integration error
Detection approach
Volume anomaly detection: compare expected vs actual order volume per distributor per day. Check for zero-volume periods during business hours — immediate alert.
Integration types to cover
Active distributors (90-day order volume)
| Distributor | Integration | Orders (90d) | Avg/day |
|---|---|---|---|
| Nordstrom | mirakl | 37,063 | ~412 |
| Macy's | mirakl | 16,330 | ~181 |
| Debenhams | mirakl | 9,887 | ~110 |
| Nordstrom Longview | mirakl | 3,182 | ~35 |
| Bloomingdales | mirakl | 2,655 | ~30 |
| FGH D2C | mirakl | 736 | ~8 |
| Needle and Thread | shopify | 661 | ~7 |
Stage 2: order_source → orders_order (Processing)
What to check
Are ingested orders being processed into orders? Query order_source where created_order_id IS NULL AND tries >= 3.
Failure modes
- No host reference found
- Duplicate order detected
- Processing error / exception
Detection query
This catches order sources that have been attempted multiple times but never successfully created an order. These are stuck in a retry loop and need manual investigation or a code fix.
Stage 3: orders_order → fulfilment (Allocation)
What to check
Are orders being sent to fulfillers? Find orders in pending or sent to dc status past expected processing time.
Failure modes
- Fulfiller didn't receive the order
- Allocation failure
- Endpoint down or misconfigured
This stage catches the Noatum/GWW scenario — orders that were created in R360 but never reached the fulfiller. Detection checks for orders that have been in an early status for longer than the expected processing window.
Stage 4: fulfilment → shipped (Dispatch)
This stage is already covered by REF-6062's dispatch SLA monitoring and EasyPost delivery tracking. Pipeline health monitoring focuses on stages 1–3 to avoid duplication.
Detection Architecture
Volume Anomaly Detection (Stage 1)
- Calculate rolling average order volume per distributor per day-of-week (last 4 weeks)
- Compare today's volume against the average
- If current volume is < 50% of expected by a certain time of day, flag as anomaly
- Different thresholds for weekdays vs weekends
- Zero-volume during business hours = immediate alert (severity: critical)
Stuck Order Detection (Stages 2–3)
- Scheduled command runs every 30 minutes
- Checks for
order_sourcerecords stuck in processing (tries >= 3, no order created) - Checks for orders stuck in early statuses past threshold
- Results exposed via API for n8n consumption
API Endpoint
n8n polls this endpoint and routes alerts based on severity: critical issues get immediate Slack alerts, warnings get included in a periodic digest.
Context: REF-3442 (Previous Attempt)
REF-3442 "Marketplace Order Error Tracking System" was created by Dotun and then canceled. It had a very detailed framework covering duplicate orders, no host references, stuck orders, and Noatum-specific issues.
Key differences in this approach
| Aspect | REF-3442 (canceled) | REF-6065 (this project) |
|---|---|---|
| Scope | Full error tracking system with ownership assignment | Detection + API — simpler, focused on surfacing issues |
| Data approach | Separate logging system | Query existing tables (order_source, orders_order) |
| Notifications | Custom notification system | n8n handles routing (Slack/email) — no custom build |
| Coverage | All stages including dispatch | Stages 1–3 only — dispatch is handled by REF-6062 |
Entity Changes
No new entities required for MVP — this is read-only monitoring of existing data.
The detection commands query order_source, orders_order, and distributor tables directly.
-
API endpoints expose detected issues new endpoint
GET /api/pipeline/issues— returns all currently detected pipeline issues with stage, severity, distributor, and age. -
Scheduled detection commands new commands
Symfony commands for stuck order detection (every 30m) and volume anomaly detection (hourly). No schema changes needed.
-
n8n polls the API for alert routing n8n workflow
n8n handles the notification layer — Slack alerts for critical, email digest for warnings. No custom notification code in R360.
pipeline_issue table could be added later if we want to track
acknowledged/resolved issues (similar to return exceptions). But the MVP can start without it —
each detection run produces a fresh view of current issues from live data.
Suggested Implementation Order
Each step is independently useful and can ship on its own:
-
Stuck order_source detection no dependency
Simplest and highest value. Scheduled command queriesorder_sourcefor records withtries >= 3and no created order. Catches processing failures immediately. Uses existing data, no schema changes. -
Volume anomaly detection per distributor no dependency
Rolling average comparison per distributor per day-of-week. Catches ingest failures — API outages, authentication expiry, integration errors. Critical alert for zero-volume during business hours. -
Allocation monitoring no dependency
Detect orders stuck in early statuses past expected processing time. Catches the Noatum/GWW scenario — orders created but never reaching the fulfiller. -
API endpoint + n8n integration depends on #1–3
Unified/api/pipeline/issuesendpoint exposing all detected issues. n8n polls and routes alerts to Slack and email based on severity.
Dependencies
REF-6062
Handles stage 4 (dispatch monitoring + delivery tracking). No overlap needed — pipeline health focuses on stages 1–3.
REF-6064
Provides the pipeline health dashboard UI. Consumes the /api/pipeline/issues endpoint to display current issues visually.