Skip to main content

LogSentinel

Log anomaly detection & root cause engine — hybrid rule-based + ML (ONNX) detector that analyzes log messages for anomalies, assigns confidence scores, and suggests probable root causes. No server required. MCP-ready for AI agents.

PyPI version Python 3.10+ License: MIT

Installation

pip install logsentinel

Quick Start

from logsentinel import LogSentinel

ls = LogSentinel()

# Analyze a single log message
result = ls.analyze("ERROR Connection refused at 192.168.1.1:5432", level="ERROR")
print(result["anomaly"])        # True
print(result["score"])          # 0.87
print(result["root_cause_hint"])  # "db"

# Batch analysis
messages = [
    "INFO Server started on port 8080",
    "ERROR OOM killer invoked, process killed",
    "DEBUG Cache hit for key user:1234",
    "CRITICAL Disk full, unable to write logs",
]
results = ls.analyze_batch(messages)
for r in results:
    if r["anomaly"]:
        print(f"ANOMALY: {r['root_cause_hint']} (score={r['score']})")

Features

Feature Description
Anomaly Detection Hybrid rule + GBM ONNX model, <5ms per log
Root Cause Engine 5 categories: db, network, memory, auth, disk
Batch Processing Analyze thousands of logs at once
MCP Tool Ready for AI agent integration
Zero Config ONNX model lazy-loaded from HuggingFace Hub
Offline Fallback Rule-based fallback if model unavailable

🤖 ML Anomaly Model (v1.0 — GBM + ONNX)

GradientBoostingClassifier trained on 50K realistic synthetic system log entries.

from logsentinel.ml_model import AnomalyModelLoader

loader = AnomalyModelLoader()
result = loader.predict("CRITICAL segfault in nginx worker", level="CRITICAL", component="gateway")
# {"anomaly": True, "score": 0.92, "confidence": "high", "root_cause_hint": "...", "model": "onnx_v1.0"}

Model details:

  • Training: 50K synthetic log entries with realistic ERROR/CRITICAL/WARNING distribution
  • Features: level_enc, component_enc, word_count, exception/timeout/connection/error_code keywords
  • Architecture: GradientBoostingClassifier → ONNX (skl2onnx)
  • Model: teyfikoz/logsentinel-anomaly-model
  • Lazy-loaded on first call → cached at ~/.cache/logsentinel/

AnomalyDetector (Low-Level API)

from logsentinel import AnomalyDetector, AnomalyResult

detector = AnomalyDetector(use_ml=True)
result = detector.detect("WARN High memory usage: 92%", level="WARNING", component="worker")
print(result.anomaly)       # False (warning level, no critical keywords)
print(result.score)         # 0.38
print(result.confidence)    # "low"

MCP Usage

pip install "logsentinel[mcp]"
# Add to your MCP config:
# {"command": "python", "args": ["-m", "logsentinel.mcp_server"]}

License

MIT — Teyfik Öz

Metadata

Release files for tey-logsentinel 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for tey-logsentinel 1.0.0
File Interpreter ABI Platform Actions
tey_logsentinel-1.0.0-py3-none-any.whl Python 3 none any Details for tey_logsentinel-1.0.0-py3-none-any.whl

Release files / tey_logsentinel-1.0.0-py3-none-any.whl

Download URL tey_logsentinel-1.0.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11b4c76216bef20daefef18a249ed98a3ca452d9d9567857a02af36d26089733
BLAKE2b-256 checksum
How to use checksums
5c8ca260a4a1366596d502adbec1c59241a4e24771fbde875b722b0d5adfc535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for tey-logsentinel 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page