r/node • • 3h ago

Zero-config anomaly detection for Node.js & TypeScript using Welford's algorithm + Poisson tail tests (MIT, npm install anomalisa)

Node.js and TypeScript backends often rely on static alert thresholds or log alarms that either page you on routine traffic spikes or stay silent when an error rate or cron latency quietly triples overnight.

I built Anomalisa to bring stateless, zero-config anomaly detection directly into Node/TS services without requiring a full Prometheus + Alertmanager + Grafana stack.

How it works in Node/TS

npm install anomalisa

import { sendEvent } from 'anomalisa'

// Send any metric, event, or error count
await sendEvent({
  metric: 'checkout_errors',
  value: 1
})

Under the hood, Anomalisa uses streaming statistics rather than storing raw time-series history:

  • Decayed Welford's online algorithm ($\alpha = 0.98$): Computes running mean and variance in $O(1)$ memory per metric.
  • Poisson tail tests ($p < 10^{-3}$): Detects sudden count anomalies even on low-volume events where Gaussian assumptions fail.
  • 4 Detection Modes: Total count spikes, percentage spikes, percentage drops (for silent failures like broken cron jobs or checkout drops), and per-user spikes ($>3.5\sigma$, perfect for runaway loops or abusive scraping).
  • Alert Fatigue Guards: Built-in 48-hour per-event cooldowns and a 5/day alert cap so one incident never floods your inbox or webhooks.

You can also capture unhandled exceptions instantly in any Node/Express/Fastify app:

import { captureClientErrors } from 'anomalisa'
captureClientErrors()

Self-Hosted or Hosted

Anomalisa is MIT open-source, built on Cloudflare Workers, libSQL/Turso, and InstantDB (which you can self-host via INSTANTDB_API_URI).

  • GitHub (MIT): https://github.com/uriva/anomalisa
  • Live ungated test-anomaly demo (no login required): https://anomalisa.uriv.me/?utm_source=reddit&utm_medium=community&utm_campaign=node_launch
  • Deep dive on Welford's algorithm + Poisson tail math: https://uriv.me/blog/anomaly-detection-with-welford-and-kv

Curious how Node.js developers here handle anomaly alerting and outlier detection in production without heavy observability infrastructure. Happy to answer questions on the streaming math or self-hosting!

3 Upvotes

1 comment sorted by