经 AI Skill Hub 精选评估,日志分析工具 获评「推荐使用」。这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 7.5 分,适合有一定技术背景的用户使用。
本地日志分析,支持个人信息遮蔽、威胁检测、异常检测
日志分析工具 是一款基于 Python 开发的开源工具,专注于 anomaly-detection、cli、devops 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
本地日志分析,支持个人信息遮蔽、威胁检测、异常检测
日志分析工具 是一款基于 Python 开发的开源工具,专注于 anomaly-detection、cli、devops 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install logatory
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install logatory
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/T0nd3/logatory
cd logatory
pip install -e .
# 验证安装
python -c "import logatory; print('安装成功')"
# 命令行使用
logatory --help
# 基本用法
logatory input_file -o output_file
# Python 代码中调用
import logatory
# 示例
result = logatory.process("input")
print(result)
# logatory 配置文件示例(config.yml) app: name: "logatory" debug: false log_level: "INFO" # 运行时指定配置文件 logatory --config config.yml # 或通过环境变量配置 export LOGATORY_API_KEY="your-key" export LOGATORY_OUTPUT_DIR="./output"
Local log analysis with PII redaction, rule-based threat detection, anomaly detection, LLM-powered insights, and a web dashboard — all running on your machine, no data leaves your infrastructure by default.

Or stay in the terminal — format auto-detected, PII redacted, threats flagged:
```text
| Capability | Details |
|---|---|
| **Format support** | Syslog, Nginx/Apache access, Apache error, HAProxy, Traefik, JSON Lines, logfmt, CEF, LEEF, plaintext — auto-detected; reads plain, gzip, and .xlsx files |
| **PII redaction** | Emails, IPv4/IPv6, credit cards (Luhn-checked), IBANs, German phone numbers — deterministic pseudonymisation or masking |
| **Rule engine** | YAML-based rules with eq, ne, contains, startswith, endswith, re, gt, lt, gte, lte operators; multi-field AND/OR |
| **Sigma support** | Convert Sigma rules to native format |
| **Anomaly detection** | Statistical Z-score baseline over 60-second buckets, trains automatically from historical logs |
| **LLM integration** | Ollama (default), Claude, OpenAI-compatible APIs; explain findings, summarize errors, RAG Q&A |
| **Web dashboard** | FastAPI + HTMX; findings/errors table, trend chart (ECharts), inline LLM explain, log file upload |
| **Log upload** | Drag-and-drop log upload in the browser — instant scan with PII redaction, results shown inline |
| **REST API v1** | Bearer-token auth, JSON endpoints for findings, errors, stats, live event ingestion |
| **OpenSearch** | Query and analyse logs from OpenSearch / Elasticsearch clusters |
| **systemd journal** | Read logs straight from journald via journalctl — scan history or follow live |
| **Docker logs** | Read container logs straight from the Docker daemon — scan or follow, no log stack required |
| **Kubernetes** | Read pod logs through kubectl — by namespace, label selector or pod; scan or follow, no log stack required |
| **Windows Event Log** | Analyze a JSON event export anywhere (even on Linux), or read a live log on Windows via Get-WinEvent |
| **S3 / object storage** | Read log objects straight from a bucket via the aws CLI — AWS S3 or any S3-compatible store; gzip decompressed on the fly |
| **Syslog listener** | Bind UDP/TCP 514 and receive syslog (RFC 3164 / RFC 5424) from network devices, firewalls and appliances |
| **AWS CloudWatch** | Pull events from a CloudWatch log group via the aws CLI — no boto3; scan or follow live |
| **GCP Cloud Logging** | Read entries via the gcloud CLI — no google-cloud dependency; scan or follow live with native severities |
| **Remote over SSH** | Pull logs from any SSH-reachable host — no agent on the remote box; scan or follow live with auto-reconnect |
| **Grafana Loki** | Query a Loki instance with LogQL — scan or follow live |
| **Graylog** | Query a Graylog server via its search API — scan or follow live |
| **Fleet** | Declare many log sources in one file — scan, follow, and manage a whole fleet at once |
| **Finding persistence** | SQLite store for HIGH/CRITICAL findings with retention, dedup, severity filtering |
| **FP suppression** | Dismiss rules globally or per source file; reversible |
| **Markdown export** | Automated security reports from the SQLite database |
| **Plugin system** | Drop Python files into a directory to add custom rules, PII patterns, parsers and source adapters |
| **Docker** | Multi-stage image, non-root user, /data volume — production-ready |
---
pip install logatory
logatory llm index
Requirements: Python 3.11+
No log aggregation stack (ELK, Loki, Graylog) required — if your services run in Docker, Logatory reads their logs straight from the daemon. Install the optional dependency and use the native docker command:
```bash pip install 'logatory[docker]'
ollama pull gemma3:4b
```bash
LOGATORY_API_TOKEN=change-me-in-production LOGATORY_PII_SALT=a-long-random-string ```
docker build -t logatory .
docker run -d \
-p 8080:8080 \
-v logatory-data:/data \
-e LOGATORY_API_TOKEN=mytoken \
-e LOGATORY_PII_SALT=mysalt \
logatory
The container runs as a non-root user (logatory, UID 1001). The database and config are stored in /data.
Mount the host log directory and run a one-shot scan:
docker run --rm \
-v /var/log:/logs:ro \
-v logatory-data:/data \
logatory \
logatory scan /logs/syslog --track-errors
```bash
docker compose up -d
The stack starts Logatory on port 8080 with a named volume for the SQLite database.
Interactive demo and database seeding using synthetic data — no real log files, Ollama, or database required for demo run.
logatory demo [run|seed|clear]
demo runGuided CLI walkthrough of all 7 feature sections (log parsing, PII, rules, error tracking, findings, anomaly detection, LLM):
logatory demo run # pause after each section
logatory demo run --no-pause # print everything at once
demo seedPopulate the SQLite database with synthetic findings and errors so the web dashboard has something to display immediately. Inserts 25 findings spread over 14 days (for the trend chart) and 5 error groups. All records are tagged internally and never mixed with real data.
logatory demo seed
demo clearRemove every record written by demo seed. Real findings and errors are never touched.
logatory demo clear
---
Seed the database with synthetic findings and errors so the dashboard shows data immediately:
```bash
docker compose exec logatory logatory demo clear ```
Alternatively, upload a real log file via the browser at http://localhost:8080/upload for an instant, transient scan.
---
pip install 'logatory[web]' # web dashboard + REST API (FastAPI, uvicorn, Jinja2)
pip install 'logatory[docker]' # read logs from local Docker containers
pip install 'logatory[opensearch]' # OpenSearch / Elasticsearch integration
pip install 'logatory[xlsx]' # read .xlsx spreadsheet log exports
pip install 'logatory[claude]' # Anthropic Claude API
pip install 'logatory[embed]' # ChromaDB for RAG (llm ask command)
Install everything:
pip install 'logatory[web,docker,opensearch,xlsx,claude,embed]'
logatory fleet list --check
Run logatory init to generate a config.yaml (with a freshly generated PII salt), or copy config.yaml.example and adapt. When no --config is passed, Logatory looks for a config in $LOGATORY_CONFIG, ./config.yaml, then ~/.config/logatory/config.yaml.
logatory init # write ./config.yaml
logatory init --minimal # smaller starter config
logatory init -o ~/.config/logatory/config.yaml
Run logatory doctor to verify your setup — it checks that the config loads, a PII salt is set, the database directory is writable, the LLM provider is configured/reachable (and that cloud API keys are present), plugins load, and alert channels build. It exits non-zero on hard failures, so it works in CI too.
logatory doctor
logatory doctor --config ~/.config/logatory/config.yaml
```yaml
pii_rules_path: pii_rules.yaml
pii_salt: ""
api_token: ""
| Variable | Description |
|---|---|
LOGATORY_PII_SALT | Salt for PII pseudonymisation |
LOGATORY_API_TOKEN | Bearer token for REST API auth |
ANTHROPIC_API_KEY | API key when llm.provider: claude |
OPENAI_API_KEY | API key when llm.provider: openai |
GROQ_API_KEY | API key when llm.provider: groq |
MISTRAL_API_KEY | API key when llm.provider: mistral |
OPENSEARCH_USERNAME | OpenSearch basic auth username |
OPENSEARCH_PASSWORD | OpenSearch basic auth password |
OPENSEARCH_API_KEY | OpenSearch API key (id:base64key) |
OPENSEARCH_CLIENT_CERT | Path to client certificate |
OPENSEARCH_CLIENT_KEY | Path to client private key |
OPENSEARCH_CA_CERTS | Path to CA certificate bundle |
LOGATORY_CONFIG | Config file path used by logatory serve --reload |
---
logatory llm info ```
llm: provider: claude model: claude-3-5-haiku-20241022
bash export ANTHROPIC_API_KEY=sk-ant-... logatory llm info ```
All commands accept --config/-c <path> to specify a config file. Without it, Logatory auto-discovers one from (in order) $LOGATORY_CONFIG, ./config.yaml, then ~/.config/logatory/config.yaml; if none exist, built-in defaults are used.
---
llm:
provider: openai
model: gpt-4o-mini
endpoint: https://api.openai.com/v1
export OPENAI_API_KEY=sk-...
Start the server (requires pip install 'logatory[web]'):
logatory serve --port 8080
Base path: /api/v1/ Interactive docs: /api/docs
| Method | Path | Description |
|---|---|---|
GET | /api/v1/health | Liveness probe (no auth) |
GET | /api/v1/findings | List findings (?severity=high&since_hours=24&source=nginx.log) |
GET | /api/v1/findings/{id} | Get finding by ID |
GET | /api/v1/errors | List error groups (?sort=count) |
GET | /api/v1/errors/{fingerprint} | Get error group + recent occurrences |
GET | /api/v1/stats | Aggregate counts |
POST | /api/v1/events | Ingest a raw log line → returns triggered findings |
Authentication
Set api_token in config.yaml or via LOGATORY_API_TOKEN. Pass it as:
Authorization: Bearer <token>
Leave empty to disable auth (for local development or Docker with network-level access control).
Event ingestion example
curl -X POST http://localhost:8080/api/v1/events \
-H "Authorization: Bearer mytoken" \
-H "Content-Type: application/json" \
-d '{"raw": "Failed password for root from 1.2.3.4 port 22", "source": "sshd"}'
Drop Python files into a directory and register custom rules, PII patterns, log-format parsers and source adapters. Enable in config.yaml:
plugins_dir: plugins/
A plugin file must expose a register(registry) function:
```python
def register(registry) -> None: # Custom detection rule registry.add_rule({ "id": "MY_DB_LEAK", "title": "Database credentials exposed in log", "description": "Fires when a connection string appears in a log message.", "level": "critical", "detection": { "match": [ {"field": "message", "op": "re", "value": r"postgresql://\S+:\S+@"}, ] }, })
# Custom PII pattern — redacts internal employee IDs registry.add_pii_pattern( name="employee_id", pattern=r"\bEMP-\d{4,8}\b", prefix="employee", )
# Load an entire directory of YAML rule files from pathlib import Path registry.add_rule_dir(Path(file).parent / "my_rules")
# Custom log-format parser — auto-detected like any built-in format # registry.add_parser(name="myfmt", detect=looks_like_myfmt, factory=MyParser)
# Custom source adapter — looked up by name like any built-in source # registry.add_adapter(name="kafka", adapter_cls=KafkaAdapter) ```
Plugin rules participate in logatory scan, logatory tail, and the web dashboard rule engine. Plugin PII patterns apply to every redaction pass; plugin parsers and adapters register into the global parser/adapter registries, so format auto-detection and source lookup pick them up everywhere. A plugin that raises an exception is logged as a warning and skipped — it never crashes the host process.
A complete, runnable example covering all four contribution types lives in plugins/example_plugin.py, and the full guide is in docs/PLUGINS.md.
---
logatory agent ask "Why did the API start failing this afternoon?"
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
AI Skill Hub 点评:日志分析工具 的核心功能完整,质量良好。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | logatory |
| Topics | anomaly-detectionclidevopsfastapillmpython |
| GitHub | https://github.com/T0nd3/logatory |
| License | Apache-2.0 |
| 语言 | Python |
收录时间:2026-06-13 · 更新时间:2026-06-13 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。