P / 03 — Streaming · Open source

stream-sentinel Telemetry Anomalies.

Online anomaly detection for fleet telemetry — constant-memory detectors, a transport-agnostic stream engine, and an evaluation harness that scores detectors the way operators experience them: recall, precision, and how many seconds until the alert fires. Pure standard library, zero dependencies.

CUSUM EWMA Robust MAD Streaming Zero deps
100%
Fault recall (45/45)
78s
Median detection latency
2.4M
Readings/sec, one core
0
Runtime dependencies
01 / Context

The detector someone unplugs by Friday.

Every naive streaming detector fails the same way: it learns the anomaly into its own baseline. EWMA variance inflates during a slow ramp until the fault is invisible; a median window absorbs a drift and hides it; CUSUM latches into permanent alarm after a level shift and pages forever. stream-sentinel ships the fix for each failure mode — learn-gating, robust window admission, classic CUSUM restart — and the test suite proves they stay fixed.

The simulator injects three realistic fault types (gradual engine overheats, fuel leaks, sudden oil-pressure drops) with exact onset timestamps, so detection quality is measured, not estimated.

02 / Results in data

The benchmark, visualised.

Charts below are the actual output of stream-sentinel --vehicles 50 --hours 4: 216,000 readings, 45 injected faults, seeded and deterministic.

Anatomy of a detection — engine overheat, vehicle VH003

Real simulated trace: temperature ramps +25°C over four minutes. All three detectors fire inside the fault window — CUSUM first at 75s, EWMA at 85s, MAD at 165s — then re-arm instead of paging forever.

shaded band = injected fault window (0–850s) · dashed lines = first alert per detector

Recall & precision by detector

Across all 45 injected faults on 150 vehicle-channel streams.

EWMA & CUSUM: perfect recall · MAD: zero false alerts

Median detection latency

Seconds from fault onset to first alert (10s reading interval).

readings arrive every 10s — EWMA fires within ~8 readings
pip install -e ".[dev]" && pytest
14 passed in 0.67s
stream-sentinel --vehicles 50 --hours 4
ewma_z recall=100.0% (45/45) precision=81.6% median latency=78s [2,424,441 readings/s]
03 / Design

How it works.

  • O(1) state per stream: EWMA and CUSUM keep a handful of floats per vehicle × channel; a fleet of thousands fits in memory with room to spare.
  • Transport-agnostic engine: consumes any iterable of readings — swapping the simulator for a Kafka consumer or MQTT subscription is a for-loop.
  • Debounce at two levels: detectors require consecutive anomalous samples; the engine enforces a per-stream re-arm interval. One fault → one page.
  • Quality bar in CI: tests enforce recall ≥ 70% and precision ≥ 70% for every detector on a fresh simulated fleet — regressions fail the build, not the on-call.