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.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: drift_sre-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3fc86e103dd0d48b59a6b50add1e6cdb88837924669a8afe08a5a7c1ff586d89
MD5 e4ab7bdc66515e13a6a4a516a296c839
BLAKE2b-256 3c57ce96d6c48c7f4a086b4d2c6fafbeb3de46c842dd755d971557917bc2e953

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