Skip to main content

logreducer

Reduce gigabytes of logs to a small, representative sample. By default you get a couple of examples of each recurring pattern, and the repeats are dropped.

It ships as a CLI and as a Python library with an IO-agnostic core.

What it gives you

  • A logreducer command that reduces a file, a SQL or ClickHouse query, or a Kafka topic, straight from the shell.
  • Pattern mode streams through a bounded dedup cache, fuzzy index and template store, so memory does not grow with the line count. Line length and the spread of token counts per line still add to it.
  • A memory budget that decides how a file is read: whole, in chunks, or reservoir-sampled once it passes five times the budget.
  • Four modes: pattern (Drain3 template mining), anomaly (Isolation Forest), temporal (one example per template per time window) and hybrid.
  • Lines naming ERROR, FATAL or CRITICAL as a whole word, in any case, come through ahead of the reduced output, one per distinct message once standalone numbers, IPs, MACs, UUIDs, hex IDs and ISO timestamps are masked, in every mode and however a file is read, up to max_severe_shapes messages (max_patterns by default). A SQL or ClickHouse source samples in the database first, so a line the sample drops is never seen.
  • A core with no IO dependencies: anything re-iterable that yields str lines is a source, and anything with write(lines) is a sink.
  • Seeded SQL sampling, PostgreSQL TABLESAMPLE and ClickHouse SAMPLE for large tables, and reduce_to_target to collect about N representative lines from a large source, holding roughly one batch in memory.
  • Injection points for a host application's config cascade and logging.

Install it and reduce a list of lines:

uv add logreducer
from logreducer import LogReducer

lines = [f"INFO GET /health 200 req={i}" for i in range(500)]
lines += [f"WARN slow query table=events ms={300 + i}" for i in range(40)]

reduced = LogReducer().reduce(lines)
print(len(lines), "->", len(reduced))
for line in reduced:
    print(line)
540 -> 4
WARN slow query table=events ms=300
WARN slow query table=events ms=301
INFO GET /health 200 req=0
INFO GET /health 200 req=1

From the shell it is logreducer app.log -o reduced.log. level is standard, enhanced or maximum, trading speed for wider coverage on a 0.5, 1 or 2 GB budget.

Extras add adapters and fuzzy dedup:

Extra Adds
enhanced Fuzzy dedup with MinHash LSH (the index holds the last dedup_cache_size near-unique lines) and faster hashing
sql SQLSource over SQLAlchemy, with a DBAPI driver you install
clickhouse ClickHouseSource over clickhouse-connect
kafka KafkaSource and KafkaSink over confluent-kafka

Template mining is derived from Drain3, MIT licence, with its licence text in the module header.

Docs and source are at https://github.com/hyperi-io/logreducer. PyPI lists the Python floor under Meta. Licensed Apache-2.0: https://github.com/hyperi-io/logreducer/blob/main/LICENSE.

Metadata

Release files for logreducer 3.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logreducer 3.5.7
File Size Uploaded Provenance Actions
logreducer-3.5.7.tar.gz 66.3 kB Without provenance Details for logreducer-3.5.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for logreducer 3.5.7
File Interpreter ABI Platform Actions
logreducer-3.5.7-py3-none-any.whl Python 3 none any Details for logreducer-3.5.7-py3-none-any.whl

Total release size: 138.6 kB

Release files / logreducer-3.5.7.tar.gz

Download URL logreducer-3.5.7.tar.gz
Size 66.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cc8631ff5c6ee99f1e05f2058201e40d84a36ea2064c604f1c3e05536e491ea5
BLAKE2b-256 checksum
How to use checksums
186f6220e2b38e8fd3e86490b60bea140c835e73ead0b8bde7edd41f634d1550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / logreducer-3.5.7-py3-none-any.whl

Download URL logreducer-3.5.7-py3-none-any.whl
Size 72.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
894157c5ed51746b93e4ac9fceb79f60e10db2827708e12abc917016e567f392
BLAKE2b-256 checksum
How to use checksums
b3d1bf3c917c5b442fe361379ae0444554e61a95b0c8ff9cd68dc8b81e24886c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for logreducer 3.5.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page