How clemcer/loggifly works
Project type and purpose
• LoggiFly is an open-source, standalone log-monitoring tool written in Python.
• It connects to one or more Docker daemons, watches container logs for keywords or regex patterns, and sends notifications or triggers container actions.
File structure
• Top-level files:
• Dockerfile & docker-compose.yaml → container image and orchestration
• config_template.yaml & config_example.yaml → configuration schema
• entrypoint.sh → startup script
• app/ directory:
• app.py → main orchestrator
• load_config.py → reads and watches config.yaml
• docker_monitor.py → connects to Docker API, streams logs, issues restart/stop
• line_processor.py → parses log lines, applies keyword/regex rules
• notifier.py → dispatches notifications via Ntfy, Apprise, webhooks
• requirements.txt → Python dependencies
README for additional insights
• Confirms features: multi‐line log detection, automatic config reload, container actions, remote host support, and notification channels.
Components
a. Config Layer
• External config.yaml (mounted or via env vars)
• Config Loader (load_config.py)
b. Monitoring Layer
• Docker Monitor (docker_monitor.py)
• Docker Daemon(s) – local socket or remote via DOCKER_HOST (with optional TLS or proxy)
c. Processing Layer
• Line Processor (line_processor.py) – handles multi-line entries, applies per-container and global rules
• Action Trigger → back to Docker Monitor (restart/stop commands)
d. Notification Layer
• Notifier (notifier.py)
• External Services: Ntfy server, Apprise endpoints (Slack, Discord, Telegram…), custom webhooks
e. Orchestration & Deployment
• entrypoint.sh & app.py glue everything
• Dockerfile → image
• docker-compose.yaml → service definition, volume mounts, env vars
Relationships and interactions
• Config Loader reads config → passes rules to Docker Monitor & Line Processor
• Docker Monitor opens log streams from Docker Daemon(s) → emits raw log entries
• Line Processor consumes entries → on match:
• invokes Notifier to send alerts
• invokes Action Trigger to restart/stop container via Docker Monitor
• Notifier sends HTTP requests to external notification services
Architectural patterns and principles
• Modular pipeline: clear separation of concerns (config, monitoring, processing, notifying)
• Observer pattern: file‐watcher for config reload, log stream watchers
• Plugin-style extensibility: add new notifiers or entry processors
Technologies, frameworks, and libraries
• Python 3.x
• Docker Engine API (via docker SDK)
• YAML for configuration
• HTTP clients (requests or similar) for Ntfy/Apprise/webhook
• Docker Compose for deployment, optional Docker Socket Proxy