logreducer 3.5.2__tar.gz → 3.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {logreducer-3.5.2 → logreducer-3.5.4}/PKG-INFO +28 -21
  2. {logreducer-3.5.2 → logreducer-3.5.4}/README.md +21 -12
  3. {logreducer-3.5.2 → logreducer-3.5.4}/pyproject.toml +22 -18
  4. {logreducer-3.5.2 → logreducer-3.5.4}/pyproject.toml.orig +22 -18
  5. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/anomaly.py +3 -1
  6. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/clickhouse.py +3 -1
  7. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/config.py +44 -6
  8. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/core.py +18 -15
  9. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/kafka.py +34 -8
  10. logreducer-3.5.4/src/logreducer/logging_config.py +237 -0
  11. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/memory.py +59 -10
  12. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/patterns.py +97 -62
  13. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/sampling.py +58 -5
  14. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/sources.py +7 -0
  15. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/sql.py +1 -1
  16. logreducer-3.5.4/src/logreducer/template_mining.py +453 -0
  17. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/temporal.py +26 -36
  18. logreducer-3.5.2/src/logreducer/logging_config.py +0 -194
  19. {logreducer-3.5.2 → logreducer-3.5.4}/LICENSE +0 -0
  20. {logreducer-3.5.2 → logreducer-3.5.4}/NOTICE +0 -0
  21. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/__init__.py +0 -0
  22. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/cli.py +0 -0
  23. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/py.typed +0 -0
  24. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/sinks.py +0 -0
  25. {logreducer-3.5.2 → logreducer-3.5.4}/src/logreducer/target.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: logreducer
3
- Version: 3.5.2
3
+ Version: 3.5.4
4
4
  Summary: Reduce GB-scale logs to a representative sample - streaming Python library and CLI with pattern mining and anomaly detection
5
5
  Keywords: log,logging,reduction,analysis,pattern-extraction,memory-efficient,streaming,anomaly-detection
6
6
  Author: HyperI Team
@@ -17,17 +17,15 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
17
  Classifier: Programming Language :: Python :: 3
18
18
  Classifier: Programming Language :: Python :: 3 :: Only
19
19
  Classifier: Operating System :: OS Independent
20
- Requires-Dist: drain3>=0.9.0
21
- Requires-Dist: psutil>=7.2.0
22
- Requires-Dist: loguru>=0.7.3
23
- Requires-Dist: numpy>=2.0.0
24
- Requires-Dist: scikit-learn>=1.5.0
20
+ Requires-Dist: psutil>=7.2.2
21
+ Requires-Dist: numpy>=2.5.3
22
+ Requires-Dist: scikit-learn>=1.9.1
25
23
  Requires-Dist: typer>=0.27.3
26
- Requires-Dist: clickhouse-connect>=1.0 ; extra == 'clickhouse'
24
+ Requires-Dist: clickhouse-connect>=1.9.0 ; extra == 'clickhouse'
27
25
  Requires-Dist: xxhash>=4.0.1 ; extra == 'enhanced'
28
26
  Requires-Dist: datasketch>=2.0.0 ; extra == 'enhanced'
29
- Requires-Dist: confluent-kafka>=2.14.0 ; extra == 'kafka'
30
- Requires-Dist: sqlalchemy>=2.0.30 ; extra == 'sql'
27
+ Requires-Dist: confluent-kafka>=2.15.1 ; extra == 'kafka'
28
+ Requires-Dist: sqlalchemy>=2.1.3 ; extra == 'sql'
31
29
  Maintainer: HyperI Team
32
30
  Maintainer-email: HyperI Team <dev@hyperi.io>
33
31
  Requires-Python: >=3.14
@@ -45,7 +43,7 @@ Description-Content-Type: text/markdown
45
43
  # LogReducer
46
44
 
47
45
  [![PyPI](https://img.shields.io/pypi/v/logreducer?logo=pypi)](https://pypi.org/project/logreducer/)
48
- [![Python Version](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/)
46
+ [![Python Version](https://img.shields.io/badge/python-3.14%2B-blue)](https://www.python.org/)
49
47
  [![License](https://img.shields.io/badge/license-Apache--2.0-green)](LICENSE)
50
48
 
51
49
  Reduce gigabytes of logs to a small, representative sample - keeping the patterns and anomalies that matter and dropping the repetition that does not. Memory-safe streaming, temporal awareness, and ML-based anomaly detection.
@@ -68,7 +66,7 @@ Reduce gigabytes of logs to a small, representative sample - keeping the pattern
68
66
 
69
67
  ### As a CLI tool
70
68
 
71
- Install it as an isolated tool so its dependencies never clash with your other Python projects (needs Python 3.12+):
69
+ Install it as an isolated tool so its dependencies never clash with your other Python projects (needs Python 3.14+):
72
70
 
73
71
  ```bash
74
72
  uv tool install logreducer # recommended (uv)
@@ -133,7 +131,7 @@ reduced = reducer.reduce(lines)
133
131
 
134
132
  ## How it works
135
133
 
136
- Everything streams: lines flow through dedup and template mining as one generator pipeline, so the unique-line set is never materialised. Memory stays near-constant regardless of input size.
134
+ Pattern mode streams: lines flow through dedup and template mining as one generator pipeline, so the unique-line set is never materialised and memory stays near-constant regardless of input size.
137
135
 
138
136
  ```mermaid
139
137
  flowchart LR
@@ -172,7 +170,7 @@ flowchart TD
172
170
  |------|-------------|----------|
173
171
  | `pattern` | Drain3 template mining | Structured / application logs (fastest) |
174
172
  | `anomaly` | Isolation Forest outlier detection | Security and error logs |
175
- | `temporal` | Time-aware pattern analysis | Time-series and monitoring logs |
173
+ | `temporal` | One example per time window and template, most important first (`temporal_window_minutes`, capped by `max_patterns`) | Time-series and monitoring logs |
176
174
  | `hybrid` | Pattern + anomaly combined | Maximum coverage |
177
175
 
178
176
  | Level | Speed | Memory cap | Features |
@@ -268,10 +266,10 @@ logreducer --dsn postgresql://user@host/db --query "SELECT msg FROM logs" \
268
266
 
269
267
  ## Bounding memory
270
268
 
271
- The core streams, so pattern/temporal modes run in near-constant memory. The knobs:
269
+ Pattern mode streams and runs in near-constant memory. Temporal mode holds the whole source in memory, and anomaly mode holds its unique lines. The knobs:
272
270
 
273
271
  - `max_memory_gb` - the overall cap (also sizes file read strategy and the watchdog). Presets: 0.5 / 1 / 2 GB by level; values above 70% of available RAM are clamped with a warning.
274
- - `max_clusters` - LRU-bound the Drain3 template store (unbounded by default).
272
+ - `max_clusters` - LRU-bound the Drain3 template store (10,000 by default, `None` for unbounded). Mining time grows with the square of the number of templates a line is compared with, so a lower value also speeds up high-cardinality sources.
275
273
  - `anomaly_max_rows` - reservoir-cap the rows fed to anomaly detection (off by default; trades anomaly recall for a bounded matrix).
276
274
 
277
275
  ```python
@@ -337,8 +335,9 @@ reducer = logreducer.LogReducer(mode="hybrid", config=cfg)
337
335
  # ...or let logreducer read your env cascade directly: prefixed beats bare.
338
336
  cfg = logreducer.BigDialConfig.from_env("MYAPP", "LOGREDUCER") # MYAPP_MAX_MEMORY_GB wins
339
337
 
340
- # 2. Logging: your app owns the loguru sinks; logreducer registers nothing and
341
- # its records flow through YOUR handlers, formatted by YOUR standard.
338
+ # 2. Logging: your app owns the stdlib logging handlers; logreducer attaches
339
+ # nothing and its records flow through YOUR handlers, at YOUR level,
340
+ # formatted by YOUR standard.
342
341
  logreducer.setup_logging(enable=True, own_sinks=False)
343
342
  ```
344
343
 
@@ -357,6 +356,7 @@ reducer = LogReducer(
357
356
  anomaly_contamination=0.1, # expected anomaly fraction
358
357
  temporal_window_minutes=60, # grouping window for temporal mode
359
358
  max_patterns=2000, # cap on extracted patterns
359
+ min_pattern_occurrences=2, # patterns seen fewer times are dropped, except CRITICAL/FATAL/ERROR ones
360
360
  )
361
361
  ```
362
362
 
@@ -368,7 +368,7 @@ Logging is off by default. Enable it and pick a format via env vars:
368
368
  LOG_LEVEL=DEBUG LOG_FORMAT=json logreducer app.log --log
369
369
  ```
370
370
 
371
- `LOG_FORMAT=json` emits one JSON object per line for log aggregators; the default is human-readable (coloured in a terminal, plain in CI/containers). Embedding? See `own_sinks=False` above.
371
+ Logging is the standard library `logging` module, under the `logreducer` logger. `LOG_FORMAT=json` emits one JSON object per line for log aggregators (keys `timestamp`, `level`, `target`, `function`, `line_number`, `message`, `fields`); the default is human-readable (coloured in a terminal, plain in CI/containers). Embedding? See `own_sinks=False` above.
372
372
 
373
373
  ## Development
374
374
 
@@ -386,6 +386,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the toolchain, test layout (including
386
386
 
387
387
  Copyright 2026 HYPERI PTY LIMITED.
388
388
 
389
+ Credits: template mining (`src/logreducer/template_mining.py`) is derived from [Drain3](https://github.com/logpai/Drain3), Copyright (c) 2020-2022 International Business Machines and the Drain3 project contributors, MIT licence. Drain3 builds on the Drain parser in LogPAI's [logparser](https://github.com/logpai/logparser). The module header carries Drain3's licence text in full.
390
+
389
391
  ## Context
390
392
 
391
393
  Depth: [docs/architecture.md](docs/architecture.md).
@@ -406,6 +408,7 @@ it is given and drops the rest.
406
408
  | `src/logreducer/sources.py`, `sinks.py` | the two structural protocols that ARE the integration surface, plus `FileSource` and `FileSink` |
407
409
  | `src/logreducer/sql.py`, `clickhouse.py`, `kafka.py` | the optional adapters, one extra each |
408
410
  | `src/logreducer/patterns.py`, `anomaly.py`, `temporal.py` | Drain3 mining and fuzzy dedup, Isolation Forest, time-window grouping |
411
+ | `src/logreducer/template_mining.py` | the Drain template miner, derived from Drain3 (credited under License) |
409
412
  | `src/logreducer/memory.py` | `MemoryMonitor`, `BoundedDeduplicator`, the file read strategies |
410
413
  | `src/logreducer/sampling.py`, `target.py` | dialect-aware SQL sampling, and the `reduce_to_target` batch loop |
411
414
  | `src/logreducer/config.py` | `BigDialConfig`, the level presets, the `from_env` cascade |
@@ -443,17 +446,21 @@ Individually: `uv run ruff format`, `uv run ruff check --fix`,
443
446
 
444
447
  ### Where this sits
445
448
 
446
- One declared edge in `dfe-infra/suite.yaml`, and it runs the surprising way.
449
+ One declared edge in `dfe-infra/suite.yaml`.
447
450
 
448
451
  | Repo | Direction | Kind | Mechanism |
449
452
  |---|---|---|---|
450
- | dfe-engine | outbound | `python-dep-undeclared` | dfe-engine imports this library at runtime and declares NO dependency on it, deliberately. `from logreducer import LogReducer` at `sampling/service.py:200`, `from logreducer.clickhouse import ClickHouseSource` at `:236`, and `from logreducer.kafka import KafkaSource` at `sampling/kafka_reader.py:134`. All three are lazy, inside the gated `smart` and `anomaly` sampler modes, and an `ImportError` is turned into an error telling the caller to use `mode=recent` or `mode=random` instead. There is no version range to test -- install a new version alongside dfe-engine and run the tests that exercise those three sites |
453
+ | dfe-engine | outbound | `python-dep` | dfe-engine declares `logreducer[enhanced]` by range in its `pyproject.toml` and imports it lazily, inside the `smart` and `anomaly` sampler modes: `LogReducer` and `logreducer.clickhouse` in `sampling/service.py`, `logreducer.kafka` in `sampling/kafka_reader.py`. A new release is checked against that range, then taken with `uv lock --upgrade-package logreducer` and the engine's tests |
451
454
 
452
455
  `dfe-stack suite --consumer logreducer` returns an empty edge list: no repo in
453
456
  that graph is something this library depends on. The runtime dependencies
454
- (drain3, psutil, loguru, numpy, scikit-learn, typer) are packages, declared in
457
+ (psutil, numpy, scikit-learn, typer) are packages, declared in
455
458
  `pyproject.toml`, which is where they belong.
456
459
 
457
460
  The reason dfe-engine gives for not declaring the dependency -- pin it "once it
458
461
  hits public PyPI" -- has been met since 3.4.0 was published on 2026-07-03, so
459
462
  expect that edge to become an ordinary pinned dependency.
463
+
464
+ ## Issues
465
+
466
+ Open bugs: [this repo](https://github.com/hyperi-io/logreducer/issues?q=is%3Aopen+is%3Aissue+type%3ABug+-label%3Abacklog+-label%3Anext-minor) | [whole DFE suite](https://github.com/search?type=issues&q=is%3Aopen+is%3Aissue+type%3ABug+-label%3Abacklog+-label%3Anext-minor+repo%3Ahyperi-io%2Fdfe-infra+repo%3Ahyperi-io%2Fdfe-docker+repo%3Ahyperi-io%2Fdfe-deploy+repo%3Ahyperi-io%2Fdfe-engine+repo%3Ahyperi-io%2Fdfe-loader+repo%3Ahyperi-io%2Fdfe-receiver+repo%3Ahyperi-io%2Fdfe-fetcher+repo%3Ahyperi-io%2Fdfe-archiver+repo%3Ahyperi-io%2Fdfe-transform-vrl+repo%3Ahyperi-io%2Fdfe-transform-vector+repo%3Ahyperi-io%2Fdfe-transform-elastic+repo%3Ahyperi-io%2Fdfe-ui+repo%3Ahyperi-io%2Fdfe-hyperdx+repo%3Ahyperi-io%2Fscalo-rs+repo%3Ahyperi-io%2Fscalo-py+repo%3Ahyperi-io%2Flogreducer+repo%3Ahyperi-io%2Fdfe-schemas+repo%3Ahyperi-io%2Fvector-vrl+repo%3Ahyperi-io%2Fculvert+repo%3Ahyperi-io%2Fclickhouse-dfe+repo%3Ahyperi-io%2Ffactbook-rs)
@@ -1,7 +1,7 @@
1
1
  # LogReducer
2
2
 
3
3
  [![PyPI](https://img.shields.io/pypi/v/logreducer?logo=pypi)](https://pypi.org/project/logreducer/)
4
- [![Python Version](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/)
4
+ [![Python Version](https://img.shields.io/badge/python-3.14%2B-blue)](https://www.python.org/)
5
5
  [![License](https://img.shields.io/badge/license-Apache--2.0-green)](LICENSE)
6
6
 
7
7
  Reduce gigabytes of logs to a small, representative sample - keeping the patterns and anomalies that matter and dropping the repetition that does not. Memory-safe streaming, temporal awareness, and ML-based anomaly detection.
@@ -24,7 +24,7 @@ Reduce gigabytes of logs to a small, representative sample - keeping the pattern
24
24
 
25
25
  ### As a CLI tool
26
26
 
27
- Install it as an isolated tool so its dependencies never clash with your other Python projects (needs Python 3.12+):
27
+ Install it as an isolated tool so its dependencies never clash with your other Python projects (needs Python 3.14+):
28
28
 
29
29
  ```bash
30
30
  uv tool install logreducer # recommended (uv)
@@ -89,7 +89,7 @@ reduced = reducer.reduce(lines)
89
89
 
90
90
  ## How it works
91
91
 
92
- Everything streams: lines flow through dedup and template mining as one generator pipeline, so the unique-line set is never materialised. Memory stays near-constant regardless of input size.
92
+ Pattern mode streams: lines flow through dedup and template mining as one generator pipeline, so the unique-line set is never materialised and memory stays near-constant regardless of input size.
93
93
 
94
94
  ```mermaid
95
95
  flowchart LR
@@ -128,7 +128,7 @@ flowchart TD
128
128
  |------|-------------|----------|
129
129
  | `pattern` | Drain3 template mining | Structured / application logs (fastest) |
130
130
  | `anomaly` | Isolation Forest outlier detection | Security and error logs |
131
- | `temporal` | Time-aware pattern analysis | Time-series and monitoring logs |
131
+ | `temporal` | One example per time window and template, most important first (`temporal_window_minutes`, capped by `max_patterns`) | Time-series and monitoring logs |
132
132
  | `hybrid` | Pattern + anomaly combined | Maximum coverage |
133
133
 
134
134
  | Level | Speed | Memory cap | Features |
@@ -224,10 +224,10 @@ logreducer --dsn postgresql://user@host/db --query "SELECT msg FROM logs" \
224
224
 
225
225
  ## Bounding memory
226
226
 
227
- The core streams, so pattern/temporal modes run in near-constant memory. The knobs:
227
+ Pattern mode streams and runs in near-constant memory. Temporal mode holds the whole source in memory, and anomaly mode holds its unique lines. The knobs:
228
228
 
229
229
  - `max_memory_gb` - the overall cap (also sizes file read strategy and the watchdog). Presets: 0.5 / 1 / 2 GB by level; values above 70% of available RAM are clamped with a warning.
230
- - `max_clusters` - LRU-bound the Drain3 template store (unbounded by default).
230
+ - `max_clusters` - LRU-bound the Drain3 template store (10,000 by default, `None` for unbounded). Mining time grows with the square of the number of templates a line is compared with, so a lower value also speeds up high-cardinality sources.
231
231
  - `anomaly_max_rows` - reservoir-cap the rows fed to anomaly detection (off by default; trades anomaly recall for a bounded matrix).
232
232
 
233
233
  ```python
@@ -293,8 +293,9 @@ reducer = logreducer.LogReducer(mode="hybrid", config=cfg)
293
293
  # ...or let logreducer read your env cascade directly: prefixed beats bare.
294
294
  cfg = logreducer.BigDialConfig.from_env("MYAPP", "LOGREDUCER") # MYAPP_MAX_MEMORY_GB wins
295
295
 
296
- # 2. Logging: your app owns the loguru sinks; logreducer registers nothing and
297
- # its records flow through YOUR handlers, formatted by YOUR standard.
296
+ # 2. Logging: your app owns the stdlib logging handlers; logreducer attaches
297
+ # nothing and its records flow through YOUR handlers, at YOUR level,
298
+ # formatted by YOUR standard.
298
299
  logreducer.setup_logging(enable=True, own_sinks=False)
299
300
  ```
300
301
 
@@ -313,6 +314,7 @@ reducer = LogReducer(
313
314
  anomaly_contamination=0.1, # expected anomaly fraction
314
315
  temporal_window_minutes=60, # grouping window for temporal mode
315
316
  max_patterns=2000, # cap on extracted patterns
317
+ min_pattern_occurrences=2, # patterns seen fewer times are dropped, except CRITICAL/FATAL/ERROR ones
316
318
  )
317
319
  ```
318
320
 
@@ -324,7 +326,7 @@ Logging is off by default. Enable it and pick a format via env vars:
324
326
  LOG_LEVEL=DEBUG LOG_FORMAT=json logreducer app.log --log
325
327
  ```
326
328
 
327
- `LOG_FORMAT=json` emits one JSON object per line for log aggregators; the default is human-readable (coloured in a terminal, plain in CI/containers). Embedding? See `own_sinks=False` above.
329
+ Logging is the standard library `logging` module, under the `logreducer` logger. `LOG_FORMAT=json` emits one JSON object per line for log aggregators (keys `timestamp`, `level`, `target`, `function`, `line_number`, `message`, `fields`); the default is human-readable (coloured in a terminal, plain in CI/containers). Embedding? See `own_sinks=False` above.
328
330
 
329
331
  ## Development
330
332
 
@@ -342,6 +344,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the toolchain, test layout (including
342
344
 
343
345
  Copyright 2026 HYPERI PTY LIMITED.
344
346
 
347
+ Credits: template mining (`src/logreducer/template_mining.py`) is derived from [Drain3](https://github.com/logpai/Drain3), Copyright (c) 2020-2022 International Business Machines and the Drain3 project contributors, MIT licence. Drain3 builds on the Drain parser in LogPAI's [logparser](https://github.com/logpai/logparser). The module header carries Drain3's licence text in full.
348
+
345
349
  ## Context
346
350
 
347
351
  Depth: [docs/architecture.md](docs/architecture.md).
@@ -362,6 +366,7 @@ it is given and drops the rest.
362
366
  | `src/logreducer/sources.py`, `sinks.py` | the two structural protocols that ARE the integration surface, plus `FileSource` and `FileSink` |
363
367
  | `src/logreducer/sql.py`, `clickhouse.py`, `kafka.py` | the optional adapters, one extra each |
364
368
  | `src/logreducer/patterns.py`, `anomaly.py`, `temporal.py` | Drain3 mining and fuzzy dedup, Isolation Forest, time-window grouping |
369
+ | `src/logreducer/template_mining.py` | the Drain template miner, derived from Drain3 (credited under License) |
365
370
  | `src/logreducer/memory.py` | `MemoryMonitor`, `BoundedDeduplicator`, the file read strategies |
366
371
  | `src/logreducer/sampling.py`, `target.py` | dialect-aware SQL sampling, and the `reduce_to_target` batch loop |
367
372
  | `src/logreducer/config.py` | `BigDialConfig`, the level presets, the `from_env` cascade |
@@ -399,17 +404,21 @@ Individually: `uv run ruff format`, `uv run ruff check --fix`,
399
404
 
400
405
  ### Where this sits
401
406
 
402
- One declared edge in `dfe-infra/suite.yaml`, and it runs the surprising way.
407
+ One declared edge in `dfe-infra/suite.yaml`.
403
408
 
404
409
  | Repo | Direction | Kind | Mechanism |
405
410
  |---|---|---|---|
406
- | dfe-engine | outbound | `python-dep-undeclared` | dfe-engine imports this library at runtime and declares NO dependency on it, deliberately. `from logreducer import LogReducer` at `sampling/service.py:200`, `from logreducer.clickhouse import ClickHouseSource` at `:236`, and `from logreducer.kafka import KafkaSource` at `sampling/kafka_reader.py:134`. All three are lazy, inside the gated `smart` and `anomaly` sampler modes, and an `ImportError` is turned into an error telling the caller to use `mode=recent` or `mode=random` instead. There is no version range to test -- install a new version alongside dfe-engine and run the tests that exercise those three sites |
411
+ | dfe-engine | outbound | `python-dep` | dfe-engine declares `logreducer[enhanced]` by range in its `pyproject.toml` and imports it lazily, inside the `smart` and `anomaly` sampler modes: `LogReducer` and `logreducer.clickhouse` in `sampling/service.py`, `logreducer.kafka` in `sampling/kafka_reader.py`. A new release is checked against that range, then taken with `uv lock --upgrade-package logreducer` and the engine's tests |
407
412
 
408
413
  `dfe-stack suite --consumer logreducer` returns an empty edge list: no repo in
409
414
  that graph is something this library depends on. The runtime dependencies
410
- (drain3, psutil, loguru, numpy, scikit-learn, typer) are packages, declared in
415
+ (psutil, numpy, scikit-learn, typer) are packages, declared in
411
416
  `pyproject.toml`, which is where they belong.
412
417
 
413
418
  The reason dfe-engine gives for not declaring the dependency -- pin it "once it
414
419
  hits public PyPI" -- has been met since 3.4.0 was published on 2026-07-03, so
415
420
  expect that edge to become an ordinary pinned dependency.
421
+
422
+ ## Issues
423
+
424
+ Open bugs: [this repo](https://github.com/hyperi-io/logreducer/issues?q=is%3Aopen+is%3Aissue+type%3ABug+-label%3Abacklog+-label%3Anext-minor) | [whole DFE suite](https://github.com/search?type=issues&q=is%3Aopen+is%3Aissue+type%3ABug+-label%3Abacklog+-label%3Anext-minor+repo%3Ahyperi-io%2Fdfe-infra+repo%3Ahyperi-io%2Fdfe-docker+repo%3Ahyperi-io%2Fdfe-deploy+repo%3Ahyperi-io%2Fdfe-engine+repo%3Ahyperi-io%2Fdfe-loader+repo%3Ahyperi-io%2Fdfe-receiver+repo%3Ahyperi-io%2Fdfe-fetcher+repo%3Ahyperi-io%2Fdfe-archiver+repo%3Ahyperi-io%2Fdfe-transform-vrl+repo%3Ahyperi-io%2Fdfe-transform-vector+repo%3Ahyperi-io%2Fdfe-transform-elastic+repo%3Ahyperi-io%2Fdfe-ui+repo%3Ahyperi-io%2Fdfe-hyperdx+repo%3Ahyperi-io%2Fscalo-rs+repo%3Ahyperi-io%2Fscalo-py+repo%3Ahyperi-io%2Flogreducer+repo%3Ahyperi-io%2Fdfe-schemas+repo%3Ahyperi-io%2Fvector-vrl+repo%3Ahyperi-io%2Fculvert+repo%3Ahyperi-io%2Fclickhouse-dfe+repo%3Ahyperi-io%2Ffactbook-rs)
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "logreducer"
7
- version = "3.5.2"
7
+ version = "3.5.4"
8
8
  description = "Reduce GB-scale logs to a representative sample - streaming Python library and CLI with pattern mining and anomaly detection"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -35,11 +35,9 @@ keywords = [
35
35
  "anomaly-detection",
36
36
  ]
37
37
  dependencies = [
38
- "drain3>=0.9.0",
39
- "psutil>=7.2.0",
40
- "loguru>=0.7.3",
41
- "numpy>=2.0.0",
42
- "scikit-learn>=1.5.0",
38
+ "psutil>=7.2.2",
39
+ "numpy>=2.5.3",
40
+ "scikit-learn>=1.9.1",
43
41
  "typer>=0.27.3",
44
42
  ]
45
43
 
@@ -56,9 +54,9 @@ enhanced = [
56
54
  "xxhash>=4.0.1",
57
55
  "datasketch>=2.0.0",
58
56
  ]
59
- sql = ["sqlalchemy>=2.0.30"]
60
- clickhouse = ["clickhouse-connect>=1.0"]
61
- kafka = ["confluent-kafka>=2.14.0"]
57
+ sql = ["sqlalchemy>=2.1.3"]
58
+ clickhouse = ["clickhouse-connect>=1.9.0"]
59
+ kafka = ["confluent-kafka>=2.15.1"]
62
60
 
63
61
  [project.urls]
64
62
  Homepage = "https://github.com/hyperi-io/logreducer"
@@ -84,6 +82,9 @@ default = true
84
82
  module-name = "logreducer"
85
83
  module-root = "src"
86
84
 
85
+ [tool.uv.exclude-newer-package]
86
+ certifi = "2026-10-21T00:00:00Z"
87
+
87
88
  [tool.ruff]
88
89
  target-version = "py312"
89
90
  line-length = 120
@@ -280,23 +281,24 @@ no_tips = true
280
281
 
281
282
  [tool.hatch.build.targets.sdist]
282
283
  exclude = [
284
+ "/ci",
283
285
  "/hyperi-ai",
286
+ "/GEMINI.md",
284
287
  "/.claude",
285
- "/.gemini",
288
+ "/.cursor",
286
289
  "/CURSOR.md",
290
+ "/.gemini",
291
+ "/.windsurf",
292
+ "/STATE.md",
287
293
  "/CLAUDE.md",
288
- "/.cursor",
289
- "/ci",
290
- "/GEMINI.md",
291
294
  "/.github/copilot-instructions.md",
292
- "/STATE.md",
293
- "/.windsurf",
294
295
  ]
295
296
 
296
297
  [dependency-groups]
297
298
  dev = [
298
299
  "pytest>=9.0.0",
299
300
  "pytest-cov>=7.0.0",
301
+ "pytest-xdist>=3.8.0",
300
302
  "ruff>=0.16.10",
301
303
  "ty>=0.0.34",
302
304
  "mypy>=2.0",
@@ -304,9 +306,11 @@ dev = [
304
306
  "pip-audit>=2.6.0",
305
307
  "vulture>=2.16",
306
308
  "vermin>=1.6.0",
307
- "sqlalchemy>=2.0.30",
308
- "clickhouse-connect>=1.0",
309
- "confluent-kafka>=2.14.0",
309
+ "xxhash>=4.0.2",
310
+ "datasketch>=2.0.0",
311
+ "sqlalchemy>=2.1.3",
312
+ "clickhouse-connect>=1.9.0",
313
+ "confluent-kafka>=2.15.1",
310
314
  "testcontainers[clickhouse,kafka,postgres,mysql]>=4.15.0",
311
315
  "psycopg[binary]>=3.2",
312
316
  "pymysql>=1.1.0",
@@ -6,7 +6,7 @@ build-backend = "uv_build"
6
6
 
7
7
  [project]
8
8
  name = "logreducer"
9
- version = "3.5.2"
9
+ version = "3.5.4"
10
10
  authors = [
11
11
  { name = "HyperI Team", email = "dev@hyperi.io" },
12
12
  ]
@@ -43,11 +43,9 @@ keywords = [
43
43
  "anomaly-detection",
44
44
  ]
45
45
  dependencies = [
46
- "drain3>=0.9.0",
47
- "psutil>=7.2.0",
48
- "loguru>=0.7.3",
49
- "numpy>=2.0.0",
50
- "scikit-learn>=1.5.0",
46
+ "psutil>=7.2.2",
47
+ "numpy>=2.5.3",
48
+ "scikit-learn>=1.9.1",
51
49
  "typer>=0.27.3",
52
50
  ]
53
51
 
@@ -57,13 +55,13 @@ enhanced = [
57
55
  "datasketch>=2.0.0",
58
56
  ]
59
57
  sql = [
60
- "sqlalchemy>=2.0.30",
58
+ "sqlalchemy>=2.1.3",
61
59
  ]
62
60
  clickhouse = [
63
- "clickhouse-connect>=1.0",
61
+ "clickhouse-connect>=1.9.0",
64
62
  ]
65
63
  kafka = [
66
- "confluent-kafka>=2.14.0",
64
+ "confluent-kafka>=2.15.1",
67
65
  ]
68
66
 
69
67
  [project.urls]
@@ -88,6 +86,9 @@ index = [
88
86
  module-name = "logreducer"
89
87
  module-root = "src"
90
88
 
89
+ [tool.uv.exclude-newer-package]
90
+ certifi = "2026-10-21T00:00:00Z"
91
+
91
92
  [tool.ruff]
92
93
  target-version = "py312"
93
94
  line-length = 120
@@ -312,23 +313,24 @@ no_tips = true
312
313
 
313
314
  [tool.hatch.build.targets.sdist]
314
315
  exclude = [
316
+ "/ci",
315
317
  "/hyperi-ai",
318
+ "/GEMINI.md",
316
319
  "/.claude",
317
- "/.gemini",
320
+ "/.cursor",
318
321
  "/CURSOR.md",
322
+ "/.gemini",
323
+ "/.windsurf",
324
+ "/STATE.md",
319
325
  "/CLAUDE.md",
320
- "/.cursor",
321
- "/ci",
322
- "/GEMINI.md",
323
326
  "/.github/copilot-instructions.md",
324
- "/STATE.md",
325
- "/.windsurf",
326
327
  ]
327
328
 
328
329
  [dependency-groups]
329
330
  dev = [
330
331
  "pytest>=9.0.0",
331
332
  "pytest-cov>=7.0.0",
333
+ "pytest-xdist>=3.8.0",
332
334
  "ruff>=0.16.10",
333
335
  "ty>=0.0.34",
334
336
  "mypy>=2.0",
@@ -336,9 +338,11 @@ dev = [
336
338
  "pip-audit>=2.6.0",
337
339
  "vulture>=2.16",
338
340
  "vermin>=1.6.0",
339
- "sqlalchemy>=2.0.30",
340
- "clickhouse-connect>=1.0",
341
- "confluent-kafka>=2.14.0",
341
+ "xxhash>=4.0.2",
342
+ "datasketch>=2.0.0",
343
+ "sqlalchemy>=2.1.3",
344
+ "clickhouse-connect>=1.9.0",
345
+ "confluent-kafka>=2.15.1",
342
346
  "testcontainers[clickhouse,kafka,postgres,mysql]>=4.15.0",
343
347
  "psycopg[binary]>=3.2",
344
348
  "pymysql>=1.1.0",
@@ -1,6 +1,8 @@
1
1
  """Anomaly detection utilities."""
2
2
 
3
- from loguru import logger
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
4
6
 
5
7
  # Try optional imports
6
8
  try:
@@ -23,6 +23,8 @@ import re
23
23
  from collections.abc import Iterator
24
24
  from typing import TYPE_CHECKING, Any
25
25
 
26
+ from .sampling import wrap_subquery
27
+
26
28
  if TYPE_CHECKING:
27
29
  from clickhouse_connect.driver.client import Client
28
30
 
@@ -97,7 +99,7 @@ class ClickHouseSource:
97
99
  self.parameters = parameters
98
100
  self.settings = settings
99
101
  self.sample = sample
100
- self._query = f"{query} SAMPLE {float(sample)!r}" if sample is not None else query
102
+ self._query = f"{wrap_subquery(query)}SAMPLE {float(sample)!r}" if sample is not None else query
101
103
 
102
104
  @classmethod
103
105
  def from_table(
@@ -1,5 +1,7 @@
1
1
  """Configuration and tuning parameters for LogReducer."""
2
2
 
3
+ import logging
4
+ import math
3
5
  import os
4
6
  import types
5
7
  import typing
@@ -7,7 +9,8 @@ from dataclasses import dataclass, fields
7
9
  from enum import Enum
8
10
 
9
11
  import psutil
10
- from loguru import logger
12
+
13
+ logger = logging.getLogger(__name__)
11
14
 
12
15
 
13
16
  class ProcessingLevel(Enum):
@@ -55,8 +58,8 @@ class BigDialConfig:
55
58
  min_pattern_occurrences: int = 2
56
59
  anomaly_contamination: float = 0.1
57
60
  # Bound the Drain3 template store (LRU-evict beyond this many templates).
58
- # None = unbounded (default; the store grows with distinct templates).
59
- max_clusters: int | None = None
61
+ # None = unbounded (the store then grows with distinct templates).
62
+ max_clusters: int | None = 10_000
60
63
  # Cap the rows fed to anomaly detection (reservoir-sampled). Bounds the
61
64
  # TF-IDF matrix on a huge unique-line set, at the cost of anomaly recall
62
65
  # (rare lines may be sampled out). None = no cap (use every unique line).
@@ -86,6 +89,7 @@ class BigDialConfig:
86
89
  pretty_json: bool = False # Pretty print JSON output
87
90
 
88
91
  def __post_init__(self) -> None:
92
+ validate_config(self)
89
93
  # Never promise more memory than the host can give: clamp to 70% of
90
94
  # what is currently available, and say so rather than silently mutate.
91
95
  available_gb = psutil.virtual_memory().available / (1024**3)
@@ -113,13 +117,44 @@ class BigDialConfig:
113
117
  overrides: dict[str, typing.Any] = {}
114
118
  for field in fields(cls):
115
119
  for prefix in prefixes:
116
- raw = os.environ.get(f"{prefix.rstrip('_')}_{field.name.upper()}")
120
+ variable = f"{prefix.rstrip('_')}_{field.name.upper()}"
121
+ raw = os.environ.get(variable)
117
122
  if raw is not None:
118
- overrides[field.name] = _coerce_env_value(raw, field.name)
123
+ try:
124
+ overrides[field.name] = _coerce_env_value(raw, field.name)
125
+ except ValueError as exc:
126
+ raise ValueError(f"{variable}={raw!r}: {exc}") from exc
119
127
  break
120
128
  return cls(**overrides)
121
129
 
122
130
 
131
+ def validate_config(config: BigDialConfig) -> None:
132
+ """Reject values that would crash a run later or silently empty its output.
133
+
134
+ Raises:
135
+ ValueError: Naming the first field that is out of range.
136
+ """
137
+ for name in ("dedup_cache_size", "temporal_window_minutes", "max_patterns", "examples_per_pattern"):
138
+ if getattr(config, name) < 1:
139
+ raise ValueError(f"{name} must be at least 1, got {getattr(config, name)!r}")
140
+ for name in ("max_clusters", "anomaly_max_rows"):
141
+ value = getattr(config, name)
142
+ if value is not None and value < 1:
143
+ raise ValueError(f"{name} must be at least 1 or None, got {value!r}")
144
+ if not 0 < config.max_memory_gb < math.inf:
145
+ raise ValueError(f"max_memory_gb must be finite and greater than 0, got {config.max_memory_gb!r}")
146
+ if not 0.0 <= config.drain_similarity <= 1.0:
147
+ raise ValueError(f"drain_similarity must be between 0 and 1, got {config.drain_similarity!r}")
148
+ if config.fuzzy_threshold is not None and not 0.0 < config.fuzzy_threshold <= 1.0:
149
+ raise ValueError(f"fuzzy_threshold must be in (0, 1] or None, got {config.fuzzy_threshold!r}")
150
+ if not 0.0 < config.anomaly_contamination <= 0.5:
151
+ raise ValueError(f"anomaly_contamination must be in (0, 0.5], got {config.anomaly_contamination!r}")
152
+
153
+
154
+ _TRUE_WORDS = frozenset({"1", "true", "yes", "on"})
155
+ _FALSE_WORDS = frozenset({"0", "false", "no", "off", ""})
156
+
157
+
123
158
  def _coerce_env_value(raw: str, field_name: str) -> object:
124
159
  """Coerce an env string to the annotated type of a BigDialConfig field."""
125
160
  hints = typing.get_type_hints(BigDialConfig)
@@ -131,7 +166,10 @@ def _coerce_env_value(raw: str, field_name: str) -> object:
131
166
  return None
132
167
  target = args[0]
133
168
  if target is bool:
134
- return raw.strip().lower() in ("1", "true", "yes", "on")
169
+ word = raw.strip().lower()
170
+ if word not in _TRUE_WORDS | _FALSE_WORDS:
171
+ raise ValueError("expected a boolean (true/false, yes/no, on/off, 1/0)")
172
+ return word in _TRUE_WORDS
135
173
  if target is int:
136
174
  return int(raw)
137
175
  if target is float: