Skip to main content

๐Ÿ”ฌ sherlog

Turn raw logs into incident postmortems โ€” zero setup, fully local.

PyPI version Python 3.11+ License: MIT PRs Welcome CI

sherlog ingests logs from multiple services, correlates them by timestamp, detects anomalies, and outputs a structured incident postmortem โ€” all from your terminal.

No agents. No cloud. No account. Just logs in, postmortem out.


๐ŸŽฌ Demo

$ sherlog --file api.log --file worker.log --file nginx.log

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿ”ฌ sherlog  โ€” incident postmortem generator โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ“‚ Reading: api.log       โœ“ 16 events  (api)
๐Ÿ“‚ Reading: worker.log    โœ“ 11 events  (worker)
๐Ÿ“‚ Reading: nginx.log     โœ“ 11 events  (nginx)

โฑ  Building timeline...
๐Ÿ” Running anomaly detection...
   โš   9 anomalies detected

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ๐Ÿ“Š Summary โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Total events   38                        โ”‚
โ”‚ Errors         15  (39.5%)               โ”‚
โ”‚ Warnings        5                        โ”‚
โ”‚ Services       api, nginx, worker        โ”‚
โ”‚ Window         14:00:00 โ†’ 14:10:25       โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ๐Ÿšจ Anomalies โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ 14:03:00  CRITICAL  error_spike              โ”‚
โ”‚           Error rate jumped to 93.3%         โ”‚
โ”‚                                              โ”‚
โ”‚ 14:03:01  ERROR     cascade                  โ”‚
โ”‚           worker erroring 14s after api      โ”‚
โ”‚                                              โ”‚
โ”‚ 14:03:10  WARNING   silence                  โ”‚
โ”‚           No logs from nginx for 430s        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โœ… Done.

โœจ Why sherlog?

Every observability tool assumes you have a budget, a team, and weeks to set up agents.

sherlog assumes you have a terminal and a log file.

sherlog Datadog Incident.io
Setup time 30 seconds Days Weeks
Cost Free $$$ $$
Agents required โŒ โœ… โœ…
Cloud account โŒ โœ… โœ…
Logs leave machine โŒ Never โœ… โœ…
Works offline โœ… โŒ โŒ
Works in air-gapped envs โœ… โŒ โŒ

๐Ÿš€ Install

pip install sherlog==0.1.0

Requires Python 3.11+


โšก Quick Start

# Analyze a single log file
sherlog --file app.log

# Multiple services at once
sherlog --file api.log --file worker.log --file nginx.log

# Filter to your incident window
sherlog --file api.log --from "2026-08-04 14:00" --to "2026-08-04 16:00"

# Read from a Docker container
sherlog --docker my-api --since 2h

# Pipe from kubectl
kubectl logs my-pod --since=2h | sherlog --stdin --stdin-service api

# Save a Markdown postmortem
sherlog --file api.log --output markdown --save ./postmortem-2026-08-04.md

๐Ÿ“‹ All Options

Options:
  -f, --file TEXT            Log file(s) to analyze
  -s, --service TEXT         Override service name (matches --file positionally)
  -d, --docker TEXT          Docker container name(s)
      --since TEXT           Docker --since value e.g. 2h, 30m
      --stdin                Read from stdin
      --stdin-service TEXT   Service name for stdin input  [default: stdin]
      --from TEXT            Start of time window (YYYY-MM-DD HH:MM:SS)
      --to TEXT              End of time window   (YYYY-MM-DD HH:MM:SS)
  -o, --output TEXT          Output format: terminal | markdown | json
      --save TEXT            Save report to file
      --bucket INTEGER       Bucket size in seconds for rate analysis [default: 60]
      --help                 Show this message and exit.

๐Ÿ“ Supported Log Formats

Format is auto-detected โ€” you never need to specify it.

JSON (pino, winston, structlog, zerolog)

{"time":"2026-08-04T14:03:05Z","level":"error","msg":"DB timeout","service":"api"}

logfmt

ts=2026-08-04T14:03:05Z level=error msg="job failed" service=worker

Plaintext (nginx, syslog, any custom format)

2026-08-04 14:03:05 ERROR upstream returned 502 Bad Gateway

๐Ÿšจ Anomaly Detection

sherlog runs three detectors on every analysis:

1. Error Spike

Detects when the error rate suddenly jumps above baseline.

14:00 โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  2%   normal
14:01 โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  3%   normal
14:02 โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  5%   normal
14:03 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 93%   โ† CRITICAL: error spike detected

2. Cascading Failure

Detects when Service B starts failing shortly after Service A โ€” suggesting an upstream dependency failure.

14:03:01  api     โ†’ first ERROR
14:03:05  nginx   โ†’ first ERROR  (4s later  โ†’ cascade detected)
14:03:15  worker  โ†’ first ERROR  (14s later โ†’ cascade detected)

3. Service Silence

Detects when a service stops emitting logs unexpectedly.

14:03:10  nginx  last log before silence
              โ†•  430 seconds โ€” no logs
14:10:20  nginx  logs resume

๐Ÿ“„ Output Formats

Terminal (default)

Rich colored output with summary panel, anomaly table, and top errors.

Markdown

sherlog --file api.log --output markdown

Outputs a complete postmortem document:

# ๐Ÿ”ฌ Incident Postmortem
> Generated by sherlog v0.1.0

## ๐Ÿ“Š Summary
| Window   | 2026-08-04 14:00:00 โ†’ 14:10:25 UTC |
| Duration | 10m 25s                             |
| Errors   | 15 (39.5%)                          |

## ๐Ÿšจ Anomalies Detected
### 1. ๐Ÿ”ด Error spike detected
...

## ๐Ÿ• Event Timeline
...

## โœ… Action Items
- [ ] Identify root cause
- [ ] Add alerting for recurrence

JSON

sherlog --file api.log --output json

Machine-readable output for scripting or integrations.


๐Ÿ—๏ธ Architecture

Ingest โ†’ Parse โ†’ Correlate โ†’ Detect โ†’ Report
Layer Job
Ingest Read raw lines from files, Docker, or stdin
Parse Convert each line into a structured LogEvent
Correlate Merge all services into one sorted timeline
Detect Find error spikes, silences, and cascades
Report Render Markdown, JSON, or terminal output

Every layer has a single input and output type โ€” swap any layer independently without touching the rest.


๐Ÿ—บ๏ธ Roadmap

  • v0.1 โ€” File ingestion, auto-detect format, timeline, anomaly detection, Markdown report
  • v0.2 โ€” Latency anomaly detection, HTML report output
  • v0.3 โ€” Custom log format config (.sherlog.yaml)
  • v0.4 โ€” Local LLM root cause summary via Ollama (offline AI, no API key)
  • v1.0 โ€” Full docs site, 80%+ test coverage, GitHub Actions CI/CD

๐Ÿค Contributing

Contributions are welcome! Here's how to get started:

# Clone the repo
git clone https://github.com/yourusername/sherlog
cd sherlog

# Create virtual environment
uv venv
source venv/bin/activate

# Install with dev dependencies
uv pip install -e ".[dev]"

# Run tests
python -m pytest tests/ -v

Please open an issue before submitting a large PR โ€” let's discuss the approach first.

See CONTRIBUTING.md for full guidelines.


๐Ÿ’ฌ FAQ

Does sherlog send my logs anywhere? Never. Everything runs locally on your machine. No network calls are made.

What Python version do I need? Python 3.11 or higher.

Can I use this in CI/CD? Yes. Use --output json for machine-readable output and --save to persist the report as an artifact.

My log format isn't being detected correctly. What do I do? Open an issue with a sample (sanitized) log line and we'll add support. Format detection is a moving target and community samples help a lot.

Will you add real-time monitoring? No. sherlog is intentionally a post-incident tool. Use Prometheus, Grafana, or Datadog for real-time monitoring. Use sherlog after the incident to understand what happened.


๐Ÿ“ License

MIT ยฉ Tharun


Built for the developer who gets paged at 2am with nothing but a terminal.

Download files

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

Source Distribution

sherlog_cli-0.1.2.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

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

sherlog_cli-0.1.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file sherlog_cli-0.1.2.tar.gz.

File metadata

  • Download URL: sherlog_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sherlog_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 736febe83b1f905ffac4e7deddb7457b37251cfa9e8c53852d47cf8d1a8ce69b
MD5 dc4b6d5903cb932f2c3507acdfc2cd6d
BLAKE2b-256 01acd1eca8466a90f61fe95b387f3723c6936c66e877a0e1dd868f2cc787d079

See more details on using hashes here.

File details

Details for the file sherlog_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sherlog_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sherlog_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45b35a1602fb3de528511d95b81fbcd66d6d25532c3b5ebf80bd6e1efc43c255
MD5 afb60f401883cc21f8ae91ddb08871bf
BLAKE2b-256 65d01fd217a370262aa680ad01c079d8934b7ab83047460389e4cdfd787fd6ed

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