Skip to main content

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

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

drift_sre-0.1.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file drift_sre-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: drift_sre-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for drift_sre-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4191e3f2306c264b843bd53ed32749ec465c775f1488eb1d2a1f009e938cf88
MD5 965e3de5309ed908595e8882ced9d391
BLAKE2b-256 d59c1f9187fe0d5a1e7f643e22ca4992175024df01ec4faaed2b0d82f99e61ec

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