Fast CLI for filtering very large log files by level, pattern, and time range
Project description
mzgb
mzgb (mezgeb — "record" in Amharic) is a fast CLI tool for filtering and navigating very large log files. Streams line by line — no memory issues, no matter the file size.
Filter by log level, regex pattern, or time range. Invert matches, pipe structured JSON/CSV output, scan multiple files at once, and decompress .gz/.bz2 on the fly. Works with plaintext, JSON, and logfmt. Pipes cleanly with kubectl, journalctl, cat, jq, and friends.
Install
# pip (base)
pip install mzgb
# With fast engines (Aho-Corasick + Bloom filter)
pip install "mzgb[fast]"
# With Drain3 template clustering
pip install "mzgb[drain]"
# Everything
pip install "mzgb[all]"
# pipx (isolated, recommended)
pipx install mzgb
# Homebrew (macOS)
brew tap mukesudo/mzgb && brew install mzgb
# Scoop (Windows)
scoop bucket add mzgb https://github.com/mukesudo/scoop-mzgb
scoop install mzgb
# Snap (Linux)
snap install mzgb --classic
# Nix
nix run github:mukesudo/mzgb
Or from source:
git clone https://github.com/mukesudo/mzgb.git
cd mzgb
python3 -m mzgb --help
Usage
# Filter by log level
mzgb --level ERROR app.log
# Pattern search with context lines
mzgb --pattern "timeout" -C 2 app.log
# Multi-pattern search (OR logic) — matches any keyword
mzgb --pattern timeout --pattern refused --pattern error app.log
# Filter by time range
mzgb --from "2024-01-15 14:00" --to "2024-01-15 15:00" app.log
# Invert — everything EXCEPT DEBUG
mzgb --invert --level DEBUG app.log
# Show line numbers
mzgb -n --level ERROR app.log
# Multiple files / globs
mzgb --level ERROR service-a.log service-b.log
mzgb --level ERROR /var/log/*.log
# Structured output — pipe into jq or pandas
mzgb --output json --level ERROR app.log | jq '.msg'
mzgb --output csv app.log > report.csv
# Compressed logs — .gz and .bz2
mzgb --level ERROR archive.log.gz
mzgb --level ERROR archive.log.bz2
# Pipe from anywhere
kubectl logs pod/api | mzgb --level ERROR
journalctl | mzgb --summary
# Follow live logs
mzgb --follow --level ERROR app.log
Options
| Flag | Short | Description |
|---|---|---|
--level |
-l |
Filter by log level (ERROR, WARN, INFO). Repeatable. |
--pattern |
-p |
Filter by keyword or regex. Repeatable (OR logic). |
--from / --to |
Time range filter. | |
--context |
-C |
Show N lines before and after each match. |
--invert |
-v |
Print lines that do not match. |
--line-numbers |
-n |
Prefix output with source line number. |
--no-color |
Disable ANSI color output. | |
--output |
-o |
Output format: text (default), json, csv. |
--summary |
-s |
Print a summary table with Drain3 template clustering. |
--follow |
-f |
Follow file for new lines (like tail -f). |
Development
# Run tests
python -m pytest
# Run with coverage
python -m pytest --cov=mzgb
License
MIT — see LICENSE
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mzgb-0.3.0.tar.gz.
File metadata
- Download URL: mzgb-0.3.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fb496cc9523f5d6ff9de3f8a8910eb16f159358ffed20450e6d6989befe3c0d
|
|
| MD5 |
814e6028219768023858d13565039617
|
|
| BLAKE2b-256 |
a1f0af2a8d67378cc847050ae8f4b9e81850f96f26c43c52ef1f8a36c6766c82
|
File details
Details for the file mzgb-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mzgb-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa716547a9451e6cbfa9c88368432cdd73e7533639c22d4a2e7f51a4f20047e9
|
|
| MD5 |
9d34d8a5f90018869566f067e0818f6e
|
|
| BLAKE2b-256 |
eaa7e4d0b60a5b17d5939f85a951de17aa8939626d46df27bc91bfc7193d550f
|