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 or the number of distinct lines.
  • 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, 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 holds the last dedup_cache_size 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.6

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.6
File Size Uploaded Provenance Actions
logreducer-3.5.6.tar.gz 62.5 kB Without provenance Details for logreducer-3.5.6.tar.gz

Built distribution (wheel)

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

Total release size: 132.3 kB

Release files / logreducer-3.5.6.tar.gz

Download URL logreducer-3.5.6.tar.gz
Size 62.5 kB
Tags Source
SHA-256 checksum
How to use checksums
abdb702a3c01bceeea3339c3b57d9194101808aedc9234b54d6f071cbbcbce75
BLAKE2b-256 checksum
How to use checksums
498372b922a3eb60d93e9fb4e05cbb5081b9c67043958562270f8e6cb0411b0b
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.6-py3-none-any.whl

Download URL logreducer-3.5.6-py3-none-any.whl
Size 69.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5ccace4e73230e57f213e7d762c3e9980dca41096cf5b50286aada86394aa0f
BLAKE2b-256 checksum
How to use checksums
e767772838fb774961568cd9eaa4b314178e0eae8be40e2f4696a222b9a1f960
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.6

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