Skip to main content

Flexible synthetic log generator with YAML templates, rate control, and LLM-powered template synthesis

Project description

LogSynth

CI PyPI version Python 3.11+ License: MIT

Generate realistic synthetic logs for testing, development, and benchmarking. Define patterns in YAML, control output rates, and stream to files, TCP, or UDP.

Installation

pip install logsynth

Quick Start

# Generate 100 nginx access logs
logsynth run nginx --count 100

# Stream logs at 50/sec for 5 minutes
logsynth run nginx --rate 50 --duration 5m

# Output as JSON to a file
logsynth run nginx --count 1000 --format json --output /var/log/test.log

# See what's available
logsynth presets list

Built-in Presets

Category Presets
Web nginx, apache, nginx-error, haproxy
Database redis, postgres, mysql, mongodb
Infrastructure systemd, kubernetes, docker, terraform
Security auth, sshd, firewall, audit
Application java, python, nodejs

Common Options

logsynth run <preset> [options]

--rate, -r       Lines per second (default: 10)
--count, -c      Total lines to generate
--duration, -d   Run time (30s, 5m, 1h)
--format, -f     Output format: plain, json, logfmt
--output, -o     Destination: file path, tcp://host:port, udp://host:port
--preview, -p    Show sample output and exit
--seed, -s       Random seed for reproducibility

Custom Templates

Create YAML templates for any log format:

name: my-app
format: plain
pattern: "[$ts] $level: $message"

fields:
  ts:
    type: timestamp
    format: "%Y-%m-%d %H:%M:%S"
  level:
    type: choice
    values: [INFO, WARN, ERROR]
    weights: [0.8, 0.15, 0.05]
  message:
    type: choice
    values:
      - "Request completed"
      - "Connection timeout"
      - "Database error"
logsynth run my-app.yaml --count 100

Field Types

Type Description Key Options
timestamp Date/time values format, step, jitter, tz
choice Random from list values, weights
int Random integer min, max
float Random decimal min, max, precision
ip IP addresses cidr, ipv6
uuid Random UUIDs uppercase
sequence Incrementing numbers start, step
literal Fixed value value

Advanced Features

Parallel Streams

Run multiple log types simultaneously with independent rates:

logsynth run nginx redis postgres \
  --stream nginx:rate=100 \
  --stream redis:rate=20 \
  --stream postgres:rate=10 \
  --duration 5m

Conditional Fields

Generate fields only when conditions are met:

fields:
  level:
    type: choice
    values: [INFO, ERROR]
  error_code:
    type: int
    min: 1000
    max: 9999
    when: "level == 'ERROR'"

Jinja2 Templates

Use Jinja2 for complex patterns (auto-detected):

pattern: |
  {% if level == "ERROR" %}ALERT {% endif %}{{ ts }} {{ level }}: {{ message }}

Corruption Testing

Inject malformed logs to test error handling:

logsynth run nginx --count 1000 --corrupt 5  # 5% corrupted

Burst Patterns

Simulate traffic spikes:

# 100/sec for 5s, then 10/sec for 25s, repeat
logsynth run nginx --burst 100:5s,10:25s --duration 5m

Configuration Profiles

Save and reuse settings:

logsynth profiles create high-volume --rate 1000 --format json
logsynth run nginx --profile high-volume

Custom Field Plugins

Extend with Python plugins in ~/.config/logsynth/plugins/:

from logsynth.fields import FieldGenerator, register

class HashGenerator(FieldGenerator):
    def generate(self) -> str:
        return hashlib.sha256(str(random.random()).encode()).hexdigest()[:16]
    def reset(self) -> None:
        pass

@register("hash")
def create(config: dict) -> FieldGenerator:
    return HashGenerator(config)

Docker

docker build -t logsynth .
docker run --rm logsynth run nginx --count 100

More Examples

See the examples/ directory for:

  • Jinja2 conditional templates
  • Custom plugin implementations
  • Profile configurations
  • Parallel stream scripts

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

logsynth-0.2.0.tar.gz (53.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logsynth-0.2.0-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file logsynth-0.2.0.tar.gz.

File metadata

  • Download URL: logsynth-0.2.0.tar.gz
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logsynth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7b90d46f1abe98ae1999001c9aa00b6a7c058c04747d17ceed4d667b9fcce3c1
MD5 cf8a67b96711eac2f0d2ac18b40e641f
BLAKE2b-256 3ec857da5b7c4a118cebc9a9929aded28d29e4b5d3116c2d9e884c9a32bd3463

See more details on using hashes here.

Provenance

The following attestation bundles were made for logsynth-0.2.0.tar.gz:

Publisher: publish.yml on lance0/logsynth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logsynth-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: logsynth-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logsynth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c14789bcdc7795a776df93c5be4dc3f88d99c24eab4b980e32fc41d1c8f3b88
MD5 4936882de2983396e75c1781bb94c123
BLAKE2b-256 04371bf43dded4c545bea46946316b5e6488e135afe838597236338b53d6de97

See more details on using hashes here.

Provenance

The following attestation bundles were made for logsynth-0.2.0-py3-none-any.whl:

Publisher: publish.yml on lance0/logsynth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page