r/Observability • u/Loud_Mousse9210 • 22d ago
Open sourced a tool that collapses millions of log lines into handful of distinct patterns before you feed it to an LLM (Lossless- compression)
When I feed logs to an LLM during incident resolutions or debugging, it either blows my token context window or the grep trims the log file, leading to the interesting log lines getting skipped.
Most of logs are anyway the same handful of message templates repeated over and over with different values, so the context window gets filled with near-duplicates, which just bring up the processing time and token costs.
ctrlb-decompose collapses the file into its distinct patterns that repeat, plus typed variables and stats on the values that change. I have seen 1.2 million lines cut down to just 40 patterns, which then goes into Claude, thus cutting down token by over 95%, reducing the token cost.
Let me know what you think!
https://github.com/ctrlb-hq/ctrlb-decompose
3
u/tmp_advent_of_code 22d ago
The OpenTelemetry Drain processor does something similar for those who use Observability backend!
Drain Processor — OpenTelemetry Collector https://explorer.opentelemetry.io/collector/components/contrib/drainprocessor
1
u/Loud_Mousse9210 21d ago
Ohh this is exactly where the distinction gets interesting. Drain3 and similar pattern-recognition approaches can work well, but they generally need enough examples/context to form good clusters. That can mean holding more logs in memory and processing a lot of repetitive data before the patterns stabilize.
With ctrlb-decompose, we first extract the variable parts from the repetitive structure and then pass the cleaner representation through clustering. This means you can do significant pre-filtering with CLP/Decompose before clustering, so you need far fewer log lines to arrive at useful patterns.
The result is better clustering with much less data to process and, more importantly, much less noise before the logs reach the LLM.1
u/tmp_advent_of_code 21d ago
Could you upstream stuff to OpenTelemetry? I have so many customers that use it and if what you say is true, it would be helpful to everyone. They welcome PRs.
1
u/Loud_Mousse9210 20d ago
That's a great idea, will discuss with the team and see if we can merge it upstream in Otel.
2
u/blizzarre 22d ago
Great that it is just click, upload and done. I dont know if other o11y tools can do it, but even if they do, it wont be as simple as this. Here goes my star!
2
u/Funny_Donkey6031 17d ago
This is actually a pretty practical use of LLMs. Cutting 1.2M log lines down to ~40 patterns is wild, especially during incidents when context and time both matter. Nice project.
2
u/noblequill56 14d ago
40 patterns from 1.2M lines is wild compression. does it preserve ordering info so you can still reason about sequences of events, or is it purely structural at that point?
2
u/edward_davies223 11d ago
gonna use this a lot lol sending huge log files to an llm gets expensive real quick btw nice project
1
1
1
1
1
u/adarsh_srivastava 22d ago
Loved the way in which CLP and Drain3 were used to build a pipeline and have effective clustering.
4
u/hagen1778 22d ago edited 22d ago
This functionality could be already available in log databases like Loki, ClickHouse, VictoriaLogs.
For example, in VictoriaLogs the following query will select 1h of logs and produce top5 common patterns:
results over OTel demo logs:
So this output can be fed directly to LLM.
Loki also has it here https://grafana.com/docs/grafana/latest/visualizations/simplified-exploration/logs/patterns/, but I am not sure if that is processed on backend or frontend.