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 and template store, so memory grows with the number of distinct templates, not with the line count.
  • 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.
  • ERROR, FATAL and CRITICAL lines always come through, one per distinct shape and ahead of the reduced output, in every mode and however a file is read. A SQL or ClickHouse source samples in the database first, so only the lines it returns are 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 and ClickHouse SAMPLE for tables too big to scan in full.
  • 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 own config cascade and logging.

Example

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

Extra Adds
enhanced Fuzzy dedup with MinHash LSH, whose index grows with near-unique lines, and faster hashing
sql SQLSource over SQLAlchemy, with your own DBAPI driver
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. Requires Python 3.14 or later. Licensed Apache-2.0: https://github.com/hyperi-io/logreducer/blob/main/LICENSE.

Metadata

Release files for logreducer 3.5.5

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.5
File Size Uploaded Provenance Actions
logreducer-3.5.5.tar.gz 58.8 kB Without provenance Details for logreducer-3.5.5.tar.gz

Built distribution (wheel)

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

Total release size: 125.0 kB

Release files / logreducer-3.5.5.tar.gz

Download URL logreducer-3.5.5.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29e5709db9acd87564bb8e42baf0701ca9efdc95f578b06cfa9bd0050a55c9a4
BLAKE2b-256 checksum
How to use checksums
ce823122649ca3145695b2930602e8d174f012c968fc46ef1c14901939b757b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.5-py3-none-any.whl

Download URL logreducer-3.5.5-py3-none-any.whl
Size 66.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdd056cf089ac9f08d187e68f40376d9ec8e3794f2706accc164a57b0f622334
BLAKE2b-256 checksum
How to use checksums
bc2d0c06cd5bb544f1e24cb07ebf10dc67d933d13829e6a7cc0e182365f3c7e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.5

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