Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

logparse

npm versionnpm downloadsLicense: MITNode ≥14

Homepage · GitHub · npm · All tools · Contact


Structured log parser / filter / aggregator. Auto-detects JSON, plain-text, nginx, Apache, syslog, and Python-logging. Filter by level, grep, time range; aggregate into top templates and time buckets. Works on files or stdin.

Free forever gift from vøiddo.

$ logparse app.log --top 5
TOP MESSAGE TEMPLATES
─────────────────────
847 ██████████████████ [ERROR] Failed to connect to db id=<num>
312 ██████░░░░░░░░░░░░ [WARN] Slow query id=<num> took <dur>
94 ██░░░░░░░░░░░░░░░░ [INFO] User login email=<email>
41 █░░░░░░░░░░░░░░░░░ [ERROR] Redis timeout after <dur>
12 ░░░░░░░░░░░░░░░░░░ [FATAL] Out of memory

Why logparse

grep doesn't know what a log "entry" is. jq only works on JSON. lnav is a full TUI you install for this one task. awk works but you're gonna write 3 lines every time.

logparse is one binary that:

  • auto-detects every log format in common use (JSON, text, nginx/apache combined, syslog RFC 3164, Python logging),
  • filters by level (-l error,warn), grep (-g timeout), time (--last 1h), severity threshold (--min-level warn),
  • aggregates into top-N message templates (normalized) or per-bucket counts,
  • streams with tail -f semantics or from stdin,
  • emits JSON / NDJSON / CSV envelopes for piping into jq or loading into a spreadsheet.

Install

npm install -g @v0idd0/logparse

Or one-shot with npx:

tail -f app.log | npx -y @v0idd0/logparse --min-level error

Quickstart

# Parse a mixed-format log, print colored
logparse app.log
# Just errors + warnings
logparse app.log -l error,warn
# Severity threshold (warn + error + fatal)
logparse app.log --min-level warn
# Last hour, only entries matching "timeout"
logparse app.log --last 1h -g timeout
# Top 10 noisiest templates (normalizes IDs/IPs/UUIDs)
logparse app.log --top 10
# Events per hour
logparse app.log --bucket 1h
# Dedupe consecutive repeats → "heartbeat (×327)"
logparse app.log --dedupe
# Read from stdin
tail -f app.log | logparse --min-level error
# nginx access log → JSON
logparse access.log --format nginx --json
# systemd journal → top 5 offenders
journalctl -u myapp | logparse --format syslog --top 5
# Live stream errors only
logparse -f app.log --min-level error

Supported formats (auto-detected)

FormatExample
JSON lines{"timestamp":"2026-04-22T12:00Z","level":"error","message":"boom"}
text2026-04-22 12:00:00 ERROR something failed
bracketed[2026-04-22T12:00Z] [ERROR] something failed
python-logging2026-04-22 12:00:00,123 - myapp.views - ERROR - something broke
nginx combined1.2.3.4 - - [22/Apr/2026:12:00:00 +0000] "GET / HTTP/1.1" 200 532 "-" "curl"
apache commonSame as nginx but without referer/user-agent
syslog RFC 3164Apr 22 12:00:00 host sshd[1234]: Accepted publickey for user

For HTTP access logs, status codes auto-map to levels: 5xx → error, 4xx → warn, <400 → info.

Force a specific parser with --format text|json|nginx|apache|syslog.

Options

Filters

FlagDescription
-l, --level <levels>Keep these levels (comma-sep)
--min-level <level>Keep entries at or above this severity
--after <date>Entries after date
--before <date>Entries before date
--last <offset>Last N time (1h, 30m, 7d, 500s)
-g, --grep <pattern>Keep entries matching regex
-v, --invert <pattern>Drop entries matching regex

Aggregation

FlagDescription
-c, --countTable of counts by level
--top <N>Top N message templates (IDs/IPs/UUIDs normalized)
--dedupeCollapse consecutive repeats into message (×N)
--bucket <offset>Per-bucket counts (1h, 15m, 1d)

Output

FlagDescription
--jsonJSON array
--ndjsonOne JSON object per line
--csvCSV with timestamp,level,message
-f, --followStream new lines (tail -f semantics)
--format <fmt>Force-parse as text, json, nginx, apache, or syslog
-h, --helpShow help
--versionShow version

Features worth calling out

Template extraction (--top)

Normalizes IDs, IPs, UUIDs, durations, timestamps, and big numbers out of messages, then aggregates. Turns a 50,000-line log into a 10-line signal:

 847 ██████████████████ [ERROR] Failed to connect to db id=<num>
312 ██████░░░░░░░░░░░░ [WARN] Slow query id=<num> took <dur>

Time bucketing

--bucket 1h groups events into hourly windows and prints level breakdowns as mini bars. Great for "is the error rate climbing?" without opening Grafana.

HTTP access log awareness

nginx/apache lines auto-parse into structured records with status, method, path, ip, userAgent. The --json envelope carries them through as extra fields.

Stream from anything

tail -f /var/log/app.log | logparse --min-level error is a poor man's alert pipeline. journalctl -fu myapp | logparse --top 5 gives you a live-updating "noisiest" view.

Exit codes

CodeMeaning
0Ran cleanly
1File not found, input error, or unknown command

Programmatic use

const{
parseLine, parseFile, parseString,
filterByLevel, filterAtLeast, filterByTime, filterByPattern, invertFilter,
countByLevel, topMessages, dedupe, bucketEvents, normalizeMessage,
formatOutput, parseTimeOffset,}=require('@v0idd0/logparse/src/parser');constentries=parseFile('/var/log/app.log');consterrors=filterAtLeast(entries,'error');consttop=topMessages(errors,10);// Or parse a single lineconstentry=parseLine('127.0.0.1 - - [22/Apr/2026:12:00:00 +0000] "GET / HTTP/1.1" 200 532 "-" "curl"');// => { format: 'nginx', level: 'info', extra: { status: 200, method: 'GET', path: '/' }, ... }

From the same studio

vøiddo builds sharp, free-forever CLIs for devs who are tired of paywalls:

Full catalog: tools.voiddo.com.

License

MIT © vøiddo — free forever, no asterisks.

Links


Built by vøiddo — a small studio shipping AI-flavoured products, free dev tools, Chrome extensions and weird browser games.

About

parse nginx/apache/syslog into structured records. pipe-friendly.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages