Skip to main content

Production-grade request metrics middleware and SLO alert engine for FastAPI + Redis Streams

Project description

⚡ fastapi-alertengine

Drop-in request monitoring + alerting for FastAPI — in under 60 seconds.

No Prometheus. No Grafana. No dashboards.

Just install → add middleware → get real-time alerts.


🚀 Quick Start

from fastapi import FastAPI
from fastapi_alertengine import RequestMetricsMiddleware, get_alert_engine
import redis

app = FastAPI()

redis_client = redis.Redis.from_url("redis://localhost:6379/0")

app.add_middleware(RequestMetricsMiddleware, redis=redis_client)

⚡ Live Alerts Endpoint

Expose real-time system health:

alert_engine = get_alert_engine(redis_client=redis_client)

@app.get("/health/alerts")
def alerts():
    return alert_engine.evaluate(window_size=200)

📊 Example Output

{
  "status": "ok | warning | critical",
  "metrics": {
    "overall_p95_ms": 123.4,
    "webhook_p95_ms": 234.5,
    "api_p95_ms": 110.2,
    "error_rate": 0.03,
    "anomaly_score": 0.8,
    "sample_size": 187
  }
}

⚡ What You Get Instantly

  • 📊 P95 latency (overall, API, webhook)
  • 🚨 Error rate detection (failure pressure signal)
  • 🧠 Anomaly detection vs baseline
  • ⚡ Rolling window analysis (real-time)
  • 🔌 Simple JSON health endpoint

🧠 Why This Exists

Most FastAPI monitoring stacks require:

  • Prometheus
  • Grafana
  • Complex dashboards

That's overkill for most teams.

fastapi-alertengine gives you the core signals that actually matter:

  • Is the system slowing down?
  • Are failures increasing?
  • Is something anomalous happening right now?

🏦 Financial-Grade Design

This system is derived from production infrastructure used in AnchorFlow.

Designed for:

  • High-reliability environments
  • Payment orchestration systems
  • Audit-friendly monitoring outputs

Key characteristics:

  • Deterministic P95 calculation
  • Failure pressure signal (error rate)
  • Structured JSON output for downstream systems
  • Safe middleware (never breaks request flow)

⚙️ Default Thresholds

  • P95 Warning: 1000ms
  • P95 Critical: 3000ms
  • Error Rate Critical: 20%

📦 Public API

AlertEngine
RequestMetricsMiddleware
get_alert_engine

🤖 AI-Agent Friendly

Designed for:

  • Claude Code
  • GitHub Copilot
  • Cursor

Agents can integrate it automatically in seconds.


💼 Production Setup (Starter Pack — $49)

Includes:

  • Redis + FastAPI deployment setup
  • Alert tuning for real workloads
  • Scaling patterns
  • Direct support

📩 Contact: advovowabantuevents@gmail.com


🧱 Roadmap

  • Slack / email alerting
  • Remote alert engine (SaaS)
  • Multi-service correlation
  • Lightweight dashboard

📜 Requirements

  • Python 3.10+
  • FastAPI
  • Redis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_alertengine-1.1.2.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_alertengine-1.1.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_alertengine-1.1.2.tar.gz.

File metadata

  • Download URL: fastapi_alertengine-1.1.2.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for fastapi_alertengine-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3edea9bf85df1c4a94a1a0ec99e871cc8c1871ee6b2c6a9753bd1aaa9fc230c2
MD5 a7b2e4960480a80a5cc63c7ae2d788c9
BLAKE2b-256 c8f7182f8ff7ff54fa3ddf28cafb5217cc13a3a185a3e1189d8691cd4c75831f

See more details on using hashes here.

File details

Details for the file fastapi_alertengine-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_alertengine-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 449d744acc2749aeea95e436c5e7126d4a970d92889dbc5ec1e10ffe0751f935
MD5 8adc435c0f6723101985703cbb99aebd
BLAKE2b-256 344c228700fd972696f5d8def40c3c854ec53852b2e6e061633bcc6efd2bc099

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page