Skip to main content

Infrastructure anomaly detection and monitoring tool

Project description

deta

AI Cost Tracking

PyPI Version Python License AI Cost Human Time Model

  • ๐Ÿค– LLM usage: $7.0500 (47 commits)
  • ๐Ÿ‘ค Human dev: ~$957 (9.6h @ $100/h, 30min dedup)

Generated on 2026-05-04 using openrouter/qwen/qwen3-coder-next


Infrastructure anomaly detection and monitoring tool for development environments.

PyPI Version Python License

Features

  • Manifest Scanning: Scans docker-compose, OpenAPI, package.json, and pyproject.toml files up to 3 layers deep
  • Environment Interpolation: Full ${VAR:-default} support with .env file layering and compose override merging
  • Port Parsing: Resolves host/container port mappings with protocol and host-bind support
  • Topology Building: Builds service dependency graphs with cycle detection and hub analysis
  • Anomaly Detection: Detects missing healthchecks, port conflicts, dependency cycles, and hardcoded secrets
  • Real-time Monitoring: Watches for config changes, probes HTTP/TCP health checks with concurrent probing
  • Web Dashboard: Real-time FastAPI/WebSocket dashboard with topology visualization and event stream
  • DSL Change Tracking: Structured change commands for service/port/probe state transitions
  • Topology Caching: mtime-based cache with configurable TTL to avoid redundant rescans
  • Multi-format Output: JSON, YAML graph, Mermaid, PNG (graphviz), and Semcod toon format
  • CLI Interface: scan, monitor, diff, and web commands via argparse

Installation

pip install deta

With optional dependencies:

# web dashboard (FastAPI + uvicorn + WebSocket)
pip install 'deta[web]'

# all extras
pip install deta[docker,toml,web]

Usage

Scan infrastructure

deta scan /path/to/project --depth 3 --output infra-map.json

Generate graph outputs (YAML / Mermaid / PNG)

# text graph + mermaid + json
deta scan /path/to/project --formats json,yaml,mermaid

# include online checks (localhost probes)
deta scan /path/to/project --formats json,yaml,mermaid --online

# try PNG (requires graphviz python package + graphviz binary)
deta scan /path/to/project --formats png

Generated files (configurable in deta.yaml):

  • infra-map.json
  • infra-graph.yaml
  • infra-graph.mmd
  • infra-graph.png
  • infra.toon.yaml

Monitor in real-time

deta monitor /path/to/project --interval 30 --depth 3
deta monitor . --interval 30 --depth 3

# realtime watch from scan command (regenerates outputs on each change)
deta scan /path/to/project --watch --formats json,yaml,mermaid --online

Web Dashboard

deta web /path/to/project --depth 3 --host 127.0.0.1 --port 8765

Open http://127.0.0.1:8765 โ€” real-time topology view with WebSocket event push (service up/down, port changes).

Configuration in deta.yaml:

web:
  enabled: true
  host: 127.0.0.1
  port: 8765
  refresh_seconds: 5
  cache_ttl_seconds: 30.0
  debounce_seconds: 0.5
  push_events:
    - service_added
    - service_removed
    - service_up
    - service_down

Compare with baseline

deta diff --baseline infra-map.json /path/to/project

Python API

from pathlib import Path
from deta import build_topology, scan_compose, scan_openapi, probe_all

# Build topology from manifests
topology = build_topology(Path("/path/to/project"), max_depth=3)

# Detect anomalies
anomalies = topology.detect_anomalies()
for anomaly in anomalies:
    print(f"{anomaly['severity']}: {anomaly['type']}")

# Cycle & hub analysis
cycles = topology.detect_cycles()
hubs = topology.find_hubs(min_degree=3)

# Export to JSON
import json
output = json.loads(topology.to_json())

# Probe services
results = probe_all(topology.services, max_concurrency=20)

Architecture

deta/
โ”œโ”€โ”€ scanner/          # Manifest parsing
โ”‚   โ”œโ”€โ”€ compose.py    # docker-compose.yml (with override merging)
โ”‚   โ”œโ”€โ”€ openapi.py    # OpenAPI specs
โ”‚   โ”œโ”€โ”€ npm.py        # package.json
โ”‚   โ”œโ”€โ”€ python.py     # pyproject.toml & requirements.txt
โ”‚   โ”œโ”€โ”€ env.py        # .env file loading & interpolation
โ”‚   โ””โ”€โ”€ ports.py      # Port binding parsing & resolution
โ”œโ”€โ”€ builder/          # Topology construction
โ”‚   โ”œโ”€โ”€ topology.py   # Graph, anomaly detection, cycles, hubs
โ”‚   โ””โ”€โ”€ cache.py      # mtime-based topology cache
โ”œโ”€โ”€ monitor/          # Real-time monitoring
โ”‚   โ”œโ”€โ”€ watcher.py    # File change polling
โ”‚   โ”œโ”€โ”€ prober.py     # HTTP/TCP health checks (concurrent)
โ”‚   โ””โ”€โ”€ alerter.py    # Rich console output
โ”œโ”€โ”€ formatter/        # Output formats
โ”‚   โ”œโ”€โ”€ graph.py      # YAML graph, Mermaid, PNG
โ”‚   โ””โ”€โ”€ toon.py       # Semcod toon format
โ”œโ”€โ”€ dsl/              # Change tracking DSL
โ”‚   โ””โ”€โ”€ commands.py   # service_up/down, port_added/removed
โ”œโ”€โ”€ web/              # Real-time dashboard
โ”‚   โ””โ”€โ”€ app.py        # FastAPI + WebSocket (topology, probes, events)
โ”œโ”€โ”€ integration/      # Ecosystem hooks
โ”‚   โ””โ”€โ”€ semcod.py     # sumd, pyqual, vallm, pre_deploy_check
โ”œโ”€โ”€ config.py         # deta.yaml configuration (Pydantic models)
โ”œโ”€โ”€ core.py           # Base Wup class
โ””โ”€โ”€ cli.py            # CLI entry point (scan, monitor, diff, web)

Configuration

Place deta.yaml in your project root. See deta.yaml.example for all options:

  • scan โ€” depth, include/exclude patterns
  • watch โ€” file monitoring paths and patterns
  • anomaly โ€” toggle checks, secret patterns, severity levels
  • monitor โ€” interval, probe timeout/retries, concurrency
  • output โ€” formats and file paths
  • alert โ€” console colors, min severity
  • web โ€” dashboard host/port, refresh, cache TTL, push events

Semcod Integration

deta integrates with the Semcod ecosystem:

from pathlib import Path
from deta.integration import generate_for_sumd, generate_for_pyqual, generate_for_vallm, pre_deploy_check

# Generate toon for sumd
generate_for_sumd(Path("."), output=Path("infra.toon.yaml"))

# Quality analysis for pyqual
generate_for_pyqual(Path("."), depth=3)

# Validation for vallm
generate_for_vallm(Path("."), depth=3)

# Pre-deployment validation
passed, issues = pre_deploy_check(Path("."))
if not passed:
    print("Deployment blocked:", issues)

Tests

pytest tests/ -v

Test coverage: cache invalidation, compose env interpolation, DSL commands, .env parsing, port parsing, monitor port display.

License

Licensed under Apache-2.0.

Project details


Download files

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

Source Distribution

deta-0.2.44.tar.gz (59.4 kB view details)

Uploaded Source

Built Distribution

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

deta-0.2.44-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file deta-0.2.44.tar.gz.

File metadata

  • Download URL: deta-0.2.44.tar.gz
  • Upload date:
  • Size: 59.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for deta-0.2.44.tar.gz
Algorithm Hash digest
SHA256 e6e5903279a7c5c8157ae45a6595e790b016e91ba53150e894ebb3db7ab59a8f
MD5 65a23806bc08e3a6b923b73ee4f3747b
BLAKE2b-256 8a7113ff13b95b83a795bbc68b3a6c4c875fa43cbfb0b5461b0b75b4e2e85278

See more details on using hashes here.

File details

Details for the file deta-0.2.44-py3-none-any.whl.

File metadata

  • Download URL: deta-0.2.44-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for deta-0.2.44-py3-none-any.whl
Algorithm Hash digest
SHA256 ec7ff0c380dcf2f2cd4a691dbd115d746a81c22cc8e7cad9f74d3b156974ef80
MD5 a52105a0866067702aa917a08e5dace9
BLAKE2b-256 f6d035efe32be118db600beb69bcde96751e09d6647c81ad7521aad5dc1b8bb7

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