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")
alert_engine = get_alert_engine(redis_client=redis_client)

app.add_middleware(RequestMetricsMiddleware, alert_engine=alert_engine)

⚡ Live Alerts Endpoint

Expose real-time system health:

@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.1.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.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_alertengine-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cffb2ba63c01eeea825d16dd279b32136f49d0e04a9a14461f584252dcc864cf
MD5 cf5acfa72665de0e3bc5f7aaf0a3abb3
BLAKE2b-256 a8836f0592cb6df19615a9ec1f17c7cc107901a6a754f5bd80f09a92e000ec23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_alertengine-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9a74e8dccbd42ba19b3632adcd205e868a4b284eb277e66fc1aab537865fb02
MD5 3b9704813adf8b76b35096ec447fb94b
BLAKE2b-256 49dd2f4c29d35bd92b8a59abe096e2ebb181ff9920e11cb1660b61d2aba35c6d

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