| name | log-analysis |
| description | Analyze, filter, transform, and convert log files using Kelora. Use for parsing logs, extracting patterns, investigating incidents, calculating metrics, or converting formats. |
| metadata | {"version":"2.0"} |
Log Analysis with Kelora
Kelora is a streaming log processor with embedded Rhai scripting. It auto-detects formats (JSON, logfmt, syslog, Apache/combined, CSV, and built-in application-log formats), transparently decompresses .gz/.zst input, and ships 150+ built-in functions.
Getting Help
Kelora ships its own reference on these dedicated screens — consult them before asking the user:
kelora -h - One-screen quick reference (cheat sheet)
kelora --help [KEYWORD] - Full CLI reference (searchable, e.g. --help since)
kelora --help-examples - Practical end-to-end patterns
kelora --help-functions [KEYWORD] - All 150+ functions (KEYWORD filters, e.g. --help-functions ip)
kelora --help-rhai - Rhai scripting guide and stage semantics
kelora --help-formats - Input/output format reference
kelora --help-time - Timestamp formats (--since/--until, parsing)
kelora --help-multiline - Multiline event strategies (-M)
kelora --help-regex - Regex parsing guide (-f regex:...)
Start Here: Explore Unknown Logs
When you don't know what's in a file, profile it first — no flags or regex needed:
kelora --discover app.log
kelora --drain -k msg app.log
--discover reports the detected format and how every field maps. --drain collapses noisy, near-identical messages into a handful of templates so you see what's actually happening.
Core Patterns
Filter:
kelora -l ERROR,WARN app.log
kelora --filter 'e.status >= 500' api.log
kelora --since "1 hour ago" --until now app.log
Transform:
kelora -e 'e.duration_sec = e.duration_ms / 1000' api.log
kelora -e 'e.absorb_json("data")' events.log
Convert formats:
kelora -f combined -J access.log > access.jsonl
kelora -j -F logfmt events.jsonl
kelora -f syslog -F csv syslog.log
Mixed formats in one file (cascade): try each parser per line, first success wins; the winner is tagged in _format.
kelora -f json,line mixed.log --filter 'e._format == "json"'
Metrics (one-flag aggregations, all imply -q):
kelora --freq level app.log
kelora --describe duration_ms app.log
kelora --card user.id app.log
kelora -s app.log
kelora -m -e 'track_freq("by_level", e.level)' app.log
--freq/--describe/--card are repeatable and accept dotted paths (e.g. user.id). Output as --metrics=short|full|tsv|json; tsv is auto-selected when piped, so --freq url | head gives the top-N.
Context around matches:
kelora -C 5 --filter 'e.level == "ERROR"' app.log
Field Access
e.level // Direct
e["@timestamp"] // Special chars
e.get_path("a.b.c") // Safe nested (returns () if missing)
e.has("field") // Check exists
Key Options
| Option | Purpose |
|---|
-f <fmt> | Input format (auto/json/logfmt/syslog/combined/csv/cols:.../regex:...); comma-list or repeated -f builds a cascade |
-F <fmt> | Output format (default/json/logfmt/csv/tsv/inspect/levelmap/keymap/tailmap) |
-j / -J | Shorthand for -f json / -F json |
--filter | Boolean expression filter |
-e / -E | Rhai script / script file per event |
--begin / --end | Run once before / after processing |
-l / -L | Include / exclude log levels |
-k / -K | Include / exclude top-level fields |
-n / --head | Limit output events / input lines (faster) |
--since / --until | Time-window filter (journalctl-style) |
-d / -D | Profile fields (input / final) |
--drain | Cluster lines into message templates |
--freq / --describe / --card | Frequency / numeric stats / distinct-count over a field |
-s / -m | Show stats / metrics (both imply -q) |
--span | Aggregate events into consecutive spans |
-C / -B / -A | Context lines around matches |
-P | Parallel processing (default is sequential) |
Tips
- Use
-f auto (default) — Kelora detects JSON, logfmt, syslog, combined, CSV, and named app-log formats. Use a cascade (-f json,line) for files that mix formats.
- Profile first with
--discover / --drain; preview with -n 10 or --head 100 before processing large files.
- Reach for
--freq / --describe / --card before hand-writing track_*() calls — they're the common aggregations in one flag.
- Run
kelora --help-functions KEYWORD to find a function (e.g. --help-functions ip); --help KEYWORD searches the CLI reference.