CLI Reference
Complete reference for the patterndb-yaml command-line interface.
Command Syntax
Basic Usage
# Normalize a file
patterndb-yaml --rules rules.yaml input.log > output.log
# Read from stdin (in pipelines)
cat input.log | patterndb-yaml --rules rules.yaml > output.log
# Show progress for large files
patterndb-yaml --rules rules.yaml --progress large.log > output.log
Arguments
INPUT_FILE (optional)
Type: File path Default: Reads from stdin if not specified
Input file to normalize. If not provided, reads from standard input.
# From file
patterndb-yaml --rules rules.yaml app.log
# From stdin
cat app.log | patterndb-yaml --rules rules.yaml
# From pipeline
tail -f app.log | patterndb-yaml --rules rules.yaml
Options Reference
Input Format
--rules, -r (required)
Type: File path Required: Yes
Path to YAML file containing normalization rules.
See Rules documentation for YAML format.
StdErr Control
These options control what appears on stderr (statistics, progress, explanations).
--quiet, -q
Type: Boolean Default: False
Suppress statistics output to stderr. Only normalized lines go to stdout.
# With statistics (default)
patterndb-yaml --rules rules.yaml input.log > output.log
# stderr shows: Lines processed: 100, Lines matched: 95, Match rate: 95%
# Without statistics (quiet)
patterndb-yaml --quiet --rules rules.yaml input.log > output.log
# stderr shows: nothing
Use when: Integrating into scripts where stderr should be clean.
--progress, -p
Type: Boolean Default: False
Show progress indicator for long-running processes. Automatically disabled when output is piped.
Shows:
Use when: Processing large files where you want visual feedback.
--stats-format
Type: String (table | json) Default: table
Statistics output format.
table format (default):
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ Lines processed │ 100 │
│ Lines matched │ 95 │
│ Match rate │ 95% │
└────────────────────┴───────┘
json format:
Use when: Machine-readable format needed for automation.
--explain, -e
Type: Boolean Default: False
Show explanations to stderr for why each line was matched or not matched.
Outputs diagnostic messages showing pattern matching decisions: - Which rule matched each line - Why a line didn't match any rules - Field extraction details
# See all pattern matching decisions
patterndb-yaml --explain --rules rules.yaml input.log 2> explain.log
# Debug with quiet mode (only explanations, no stats)
patterndb-yaml --explain --quiet --rules rules.yaml input.log
# Validate rules
patterndb-yaml --explain --rules rules.yaml test.log 2>&1 | grep EXPLAIN
Example output:
EXPLAIN: Line 1: Matched rule 'mysql_select'
EXPLAIN: Line 2: Matched rule 'postgres_select'
EXPLAIN: Line 3: No pattern matched - passed through
See Explain Mode for detailed usage.
XML Generation
--generate-xml
Type: Boolean Default: False
Generate syslog-ng patterndb XML from rules file and output to stdout. No log processing occurs.
This converts your YAML rules into syslog-ng's XML patterndb format for use with syslog-ng. See Generate XML for details.
Use when: Integrating with syslog-ng infrastructure.
Version Information
--version, -v
Type: Boolean Default: False
Show version and exit.
Example output:
Option Combinations
Commonly Used Together
# Silent processing (scripts)
patterndb-yaml --quiet --rules rules.yaml input.log > output.log
# Debug mode (understanding what matched)
patterndb-yaml --explain --quiet --rules rules.yaml input.log \
> output.log 2> explain.log
# Progress with JSON stats (monitoring)
patterndb-yaml --progress --stats-format json --rules rules.yaml \
input.log > output.log 2> stats.json
Mutually Exclusive Behaviors
--generate-xmloutputs XML and skips log processing (other options ignored)--quietsuppresses statistics but not--explainoutput
Examples
Normalize Production Logs
Compare Environments
# Normalize both
patterndb-yaml --rules rules.yaml --quiet prod.log > prod-norm.log
patterndb-yaml --rules rules.yaml --quiet staging.log > staging-norm.log
# Compare
diff prod-norm.log staging-norm.log
Monitor Match Coverage
# Get JSON statistics
patterndb-yaml --rules rules.yaml --stats-format json app.log 2> stats.json
# Check match rate
jq '.match_rate' stats.json
Debug Pattern Matching
# See which patterns match
patterndb-yaml --explain --rules rules.yaml test.log 2>&1 | grep "Matched rule"
# Find unmatched lines
patterndb-yaml --explain --rules rules.yaml test.log 2>&1 | \
grep "No pattern matched"
Stream Processing
Statistics Output
Table Format (Default)
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ Lines processed │ 500 │
│ Lines matched │ 475 │
│ Match rate │ 95% │
└────────────────────┴───────┘
JSON Format
Exit Codes
- 0: Success
- 1: Error (invalid arguments, file not found, processing error)
- 2: Invalid rules file (YAML syntax error, invalid pattern)
See Also
- Rules Documentation - YAML rule format
- Library API - Using as a Python library
- Basic Concepts - Understanding how it works