patterndb-yaml
YAML-based pattern matching with multi-line capabilities for log normalization using syslog-ng patterndb
What is patterndb-yaml?
patterndb-yaml brings intuitive YAML pattern definitions to syslog-ng's proven patterndb engine. Instead of writing complex XML patterns, you define rules in readable YAML and let patterndb-yaml handle the translation to syslog-ng's efficient pattern matcher.
This makes it easier to normalize heterogeneous logs - transforming different log formats into standardized output for comparison, analysis, or filtering.
Features
- YAML rules - Readable pattern definitions instead of syslog-ng XML
- Field extraction - Pull specific data (table names, IDs, etc.) from matched lines
- Pattern matching - Powered by syslog-ng's efficient C implementation
- Multi-line sequences - Handle log entries spanning multiple lines
- Explain mode - Debug which patterns matched and why
- CLI and Python API - Use as a command-line tool or library
Installation
Requirements: Python 3.9+, syslog-ng 4.10.1+
⚠️ Important:
patterndb-yamlrequires syslog-ng to be installed from official repositories (distro defaults may be incompatible).See SYSLOG_NG_INSTALLATION.md for platform-specific instructions.
Via Homebrew (macOS + Linux) - Recommended
brew tap JeffreyUrban/patterndb-yaml && brew install patterndb-yaml
✅ Automatically installs syslog-ng as a dependency. Homebrew manages all dependencies and provides easy updates via brew upgrade.
Via pipx (Alternative)
⚠️ Manual Setup Required: You must install syslog-ng separately before using pipx.
# STEP 1: Install syslog-ng from official repos (REQUIRED)
# See docs/SYSLOG_NG_INSTALLATION.md for your platform
# STEP 2: Install patterndb-yaml
pipx install patterndb-yaml
pipx installs in an isolated environment with global CLI access. Update with pipx upgrade patterndb-yaml.
Via pip
⚠️ Manual Setup Required: You must install syslog-ng separately before using pip.
# STEP 1: Install syslog-ng from official repos (REQUIRED)
# See docs/SYSLOG_NG_INSTALLATION.md for your platform
# STEP 2: Install patterndb-yaml
pip install patterndb-yaml
Use pip if you want to use patterndb-yaml as a library in your Python projects.
From Source
# Development installation
git clone https://github.com/JeffreyUrban/patterndb-yaml
cd patterndb-yaml
pip install -e ".[dev]"
Windows
Windows is not currently supported. Consider using WSL2 (Windows Subsystem for Linux) and following the Linux installation instructions.
Requirements: Python 3.9+, syslog-ng (installed automatically with Homebrew)
Quick Start
Command Line
Create a YAML rules file (rules.yaml):
rules:
- name: log_info
pattern:
- text: "["
- text: "INFO"
- text: "] "
- field: message
output: "[info:{message}]"
- name: log_error
pattern:
- text: "["
- text: "ERROR"
- text: "] "
- field: message
output: "[error:{message}]"
Process your logs:
# Process from stdin
cat app.log | patterndb-yaml --rules rules.yaml
# Process a file
patterndb-yaml --rules rules.yaml --input app.log
# Get statistics
patterndb-yaml --rules rules.yaml --input app.log --stats
Python API
from patterndb_yaml import PatterndbYaml
from pathlib import Path
# Initialize with rules
processor = PatterndbYaml(rules_path=Path("rules.yaml"))
# Process logs
with open("app.log") as infile, open("clean.log", "w") as outfile:
processor.process(infile, outfile)
# Get statistics
stats = processor.get_stats()
print(f"Matched {stats['lines_matched']} of {stats['lines_processed']} lines")
print(f"Match rate: {stats['match_rate']:.1%}")
Use Cases
- Log Normalization - Transform heterogeneous log formats into standardized output
- Data Extraction - Pull structured data from unstructured log lines
- Log Filtering - Identify and process specific log patterns
- Format Standardization - Convert legacy log formats to modern structured formats
- Compliance - Normalize logs for security analysis and auditing
How It Works
patterndb-yaml uses syslog-ng's patterndb engine for efficient pattern matching:
- YAML → XML - Converts your readable YAML rules into syslog-ng's XML patterndb format
- Pattern Matching - Uses syslog-ng's C implementation for fast, memory-efficient matching
- Field Extraction - Pulls named fields from matched patterns
- Output Transformation - Applies output templates to normalize log format
The system processes logs line-by-line with constant memory usage, making it suitable for large files and streaming data.
Documentation
Read the full documentation at patterndb-yaml.readthedocs.io
Key sections:
- Getting Started - Installation and quick start guide
- Use Cases - Real-world examples across different domains
- Guides - Pattern design, performance tips, common patterns
- Reference - Complete CLI and Python API documentation
Development
# Clone repository
git clone https://github.com/JeffreyUrban/patterndb-yaml.git
cd patterndb-yaml
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=patterndb_yaml --cov-report=html
# Build documentation
cd docs && mkdocs build
Performance
- Time complexity: O(n) where n is number of log lines
- Space complexity: O(1) constant memory for processing
- Throughput: Processes logs line-by-line with streaming support
- Memory: Minimal memory footprint, suitable for large files
Performance is determined by syslog-ng's patterndb engine, which uses efficient C implementations for pattern matching.
License
MIT License - See LICENSE file for details
Author
Jeffrey Urban
Metadata
Release files for patterndb-yaml 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| patterndb_yaml-0.2.0.tar.gz | 238.0 kB | With provenance | Details for patterndb_yaml-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patterndb_yaml-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for patterndb_yaml-0.2.0-py3-none-any.whl |
Total release size: 268.9 kB
Release files / patterndb_yaml-0.2.0.tar.gz
| Download URL | patterndb_yaml-0.2.0.tar.gz |
|---|---|
| Size | 238.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cf8a0b4a3c4ab2995eb3074dc70989c42aa4ca37aefcc3e964ff2d7710fa9ba
|
|
BLAKE2b-256 checksum How to use checksums |
0973720b0956ca345fe3012d635a3cd1954e531aff881d81eac5f15e3cd58db8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logRelease files / patterndb_yaml-0.2.0-py3-none-any.whl
| Download URL | patterndb_yaml-0.2.0-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05f54807c983fc53b8837a4a57988b62341f8ea2c49a40a97506b09e74dea26e
|
|
BLAKE2b-256 checksum How to use checksums |
e419e3ab82b820f8197f162316a816fd7bcd9a5b125647d089ff2fc9e594b69a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logSecurity for patterndb-yaml 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for patterndb_yaml-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.