Drift-SRE
Real-time Anomaly Detection Library for SRE
Drift-SRE is a lightweight, embeddable Python library that monitors server metrics and detects anomalies in real-time, with intelligent Discord notifications. Perfect for integrating into your existing applications without requiring separate services.
Quick Start
from drift import DriftMonitor
# Initialize with Discord webhook
monitor = DriftMonitor(
discord_webhook="https://discord.com/api/webhooks/YOUR_WEBHOOK_URL",
check_interval=5 # seconds
)
# Customize specific metrics (optional)
monitor.configure_metric('ram_percent', threshold=10.0, drift=2.0)
monitor.configure_metric('cpu_percent', threshold=25.0, drift=5.0)
# Start monitoring in background
monitor.start()
# That's it! Monitor runs in background thread
Installation
pip install drift-sre
Features
- Embeddable: Runs in the same process as your application
- Zero External Services: No separate monitoring server required (except Discord for notifications)
- Smart Defaults: Sensible configurations for all system metrics out of the box
- Per-Metric Tuning: Configure each metric independently with CUMSUM or EWMA algorithms
- Discord Notifications: Beautiful embeds with rate limiting and recovery notifications
- Custom Metrics: Register your own metrics with custom collectors
- Thread-Safe: Safe to use with Flask, FastAPI, Django, and other frameworks
Monitored Metrics
- CPU usage percentage
- RAM usage percentage
- Disk read/write throughput
- Network sent/received bytes
- System load average
- Active network connections
Algorithms
CUMSUM (Cumulative Sum)
Best for stable metrics like CPU and RAM. Detects sustained shifts from normal behavior.
EWMA (Exponentially Weighted Moving Average)
Best for variable metrics like network traffic and disk I/O. Adapts to changing patterns.
Documentation
- Getting Started - Installation and basic setup
- Configuration Guide - Tuning detection parameters
- Metrics Guide - Understanding each metric
- API Reference - Complete API documentation
- Advanced Usage - Custom metrics and integrations
- Troubleshooting - Common issues and solutions
Examples
See the examples directory for:
- Basic usage
- Flask integration
- FastAPI integration
- Custom metrics
Requirements
- Python 3.8+
- psutil (for system metrics)
- requests (for Discord webhooks)
License
MIT License
Contributing
Contributions welcome! Please see our contributing guidelines.
Metadata
Release files for drift-sre 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| drift_sre-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / drift_sre-0.1.2-py3-none-any.whl
| Download URL | drift_sre-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3fc86e103dd0d48b59a6b50add1e6cdb88837924669a8afe08a5a7c1ff586d89
|
|
BLAKE2b-256 checksum How to use checksums |
3c57ce96d6c48c7f4a086b4d2c6fafbeb3de46c842dd755d971557917bc2e953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|