Real-time Anomaly Detection Library for SRE with Discord notifications
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drift_sre-0.1.0.tar.gz.
File metadata
- Download URL: drift_sre-0.1.0.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4322aa95d489f09ac5f5136fba57c8e159bd1954a78239084970f4a2ede5c58a
|
|
| MD5 |
000a5cc066062f033ebdc5119481ac23
|
|
| BLAKE2b-256 |
3ded601448f1e6317dd81c861ddd88bcf728bc7ac709eb2d13ce3233cecd2d38
|
File details
Details for the file drift_sre-0.1.0-py3-none-any.whl.
File metadata
- Download URL: drift_sre-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd3a682b8f5cee5709957f7ebb12c08b2646c798c9f14b4a1011c20c9b93426d
|
|
| MD5 |
b731cfa2d7aca4c1d0dbb984eee29695
|
|
| BLAKE2b-256 |
413a54023edf98152f3a46c9aa144fcf1b1f7e07e2430190dec09079aa474669
|