Skip to main content

Metric monitoring with automatic anomaly detection

Project description

detectkit

Metric monitoring with automatic anomaly detection

detectkit is a Python library for data analysts and engineers to monitor time-series metrics with automatic anomaly detection and alerting.

Status

Production Ready - Version 0.1.2

Published to PyPI: https://pypi.org/project/detectkit/

Complete rewrite with modern architecture and full documentation (2025).

Features

  • Pure numpy arrays - No pandas dependency in core logic
  • Batch processing - Efficient vectorized operations
  • Multiple detectors - Statistical methods (Z-Score, MAD, IQR, Manual Bounds)
  • Alert channels - Mattermost, Slack, Webhook support
  • Database agnostic - ClickHouse, PostgreSQL, MySQL support
  • Idempotent operations - Resume from interruptions
  • 🚧 CLI interface - dbt-like commands (coming soon)

Installation

pip install detectkit

Or from source:

git clone https://github.com/alexeiveselov92/detectkit
cd detectkit
pip install -e .

Optional dependencies

# ClickHouse support
pip install detectkit[clickhouse]

# All database drivers
pip install detectkit[all-db]

# Development dependencies
pip install detectkit[dev]

Quick Start

CLI Usage (Recommended)

# Create a new project
dtk init my_monitoring_project
cd my_monitoring_project

# Configure database in profiles.yml
# Then run your metrics
dtk run --select example_cpu_usage

# Run specific pipeline steps
dtk run --select cpu_usage --steps load,detect

# Run all critical metrics
dtk run --select tag:critical

# Reload data from specific date
dtk run --select cpu_usage --from 2024-01-01

Python API Usage

import numpy as np
from detectkit.detectors.statistical import ZScoreDetector

# Your time-series data
timestamps = np.array([...], dtype='datetime64[ms]')
values = np.array([1.0, 2.0, 1.5, 10.0, 1.8])  # 10.0 is anomaly

# Create detector
detector = ZScoreDetector(threshold=3.0, window_size=100)

# Detect anomalies
data = {
    'timestamp': timestamps,
    'value': values
}
results = detector.detect(data)

# Check results
for result in results:
    if result.is_anomaly:
        print(f"Anomaly at {result.timestamp}: {result.value}")

Architecture

  • Detectors - Statistical and ML-based anomaly detection
  • Loaders - Metric data loading from databases with gap filling
  • Alerting - Multi-channel notifications with orchestration
  • Config - YAML-based configuration (dbt-like)

Testing

# Run tests
pytest tests/

# With coverage
pytest tests/ --cov=detectkit --cov-report=html

Current status: 287 tests passing, 87% coverage

Development Status

✅ Completed (Phases 1-6)

  • Phase 1: Core models (Interval, TableModel, ColumnDefinition)
  • Phase 2: Database managers & data loading (MetricLoader, gap filling, seasonality)
  • Phase 3: Statistical detectors (Z-Score, MAD, IQR, Manual Bounds)
  • Phase 4: Alerting system (Channels, Orchestrator, consecutive anomalies)
  • Phase 5: Task manager (Pipeline execution, locking, idempotency)
  • Phase 6: CLI commands (dtk init, dtk run with selectors)

🔄 Integration Status

  • ⚠️ Full end-to-end integration pending (database connection required)
  • ⚠️ Advanced detectors (Prophet, TimesFM) - optional extras
  • ⚠️ Additional alert channels (Telegram, Email) - optional

Documentation

📚 Complete documentation available at: https://github.com/alexeiveselov92/detectkit/tree/main/docs

Requirements

  • Python 3.10+
  • numpy >= 1.24.0
  • pydantic >= 2.0.0
  • click >= 8.0
  • PyYAML >= 6.0
  • Jinja2 >= 3.0

License

MIT License - See LICENSE file for details

Contributing

This project is currently in active development. Contributions are welcome once we reach v1.0.0.

Changelog

0.1.0 (2025-11-07)

  • Initial release with complete rewrite
  • ✅ Core foundation: models, database, config
  • ✅ Metric loading with gap filling and seasonality extraction
  • ✅ Statistical detectors (Z-Score, MAD, IQR, Manual Bounds)
  • ✅ Alert channels (Webhook, Mattermost, Slack)
  • ✅ Alert orchestration with consecutive anomaly logic
  • ✅ Task manager for pipeline execution
  • ✅ CLI commands (dtk init, dtk run)
  • 📊 287 unit tests, 87% coverage

Project details


Release history Release notifications | RSS feed

This version

0.2.4

Download files

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

Source Distribution

detectkit-0.2.4.tar.gz (72.2 kB view details)

Uploaded Source

Built Distribution

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

detectkit-0.2.4-py3-none-any.whl (95.4 kB view details)

Uploaded Python 3

File details

Details for the file detectkit-0.2.4.tar.gz.

File metadata

  • Download URL: detectkit-0.2.4.tar.gz
  • Upload date:
  • Size: 72.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for detectkit-0.2.4.tar.gz
Algorithm Hash digest
SHA256 e949b56840d0f84c9b5a24f5fa609d29d5a0f15da11cbd8b605c04071e2f188e
MD5 aba55dc36c396f173a74ff6f3a0d557b
BLAKE2b-256 444513e5dc7bf644bc51c557df20fae0bc6633a96a0a19efcc8b642b0498de62

See more details on using hashes here.

File details

Details for the file detectkit-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: detectkit-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 95.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for detectkit-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 63fbcd4318514282171836828638f65f21199d027a2d5e6c882d84ed066878c5
MD5 52b57ef34d6341f08f6e529b1aab2f93
BLAKE2b-256 6a0c6c65794295e9e54f70f5fb209f6bd645490fa7db493548af7d3c2e4feadc

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