[processor/drain] add new drain processor for log template annotation#47236
Open
MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
Open
[processor/drain] add new drain processor for log template annotation#47236MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
MikeGoldsmith wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
d78a15d to
6cf5aad
Compare
…n-telemetry#47235] Adds a new `drain` processor that applies the Drain log clustering algorithm to log records as they pass through the pipeline. For each record it derives a template string (e.g. "user <*> logged in from <*>") and attaches it as the `log.record.template` attribute. Key features: - Configurable Drain parse tree parameters (depth, sim_threshold, max_children, max_clusters, extra_delimiters) - Seeding via seed_templates or seed_logs for stable templates at startup - Two warmup modes: passthrough (annotate immediately) and buffer (hold records until the tree has stabilized, then flush fully annotated) - Optional body_field extraction for structured map log bodies - Internal telemetry: clusters_active gauge, log_records_annotated and log_records_unannotated counters Assisted-by: Claude Sonnet 4.6
4b37041 to
49a733d
Compare
Assisted-by: Claude Sonnet 4.6
go mod tidy promotes otel/metric, otel/sdk/metric, and otel/trace from indirect to direct following the addition of the TelemetryBuilder. Assisted-by: Claude Sonnet 4.6
edmocosta
reviewed
Apr 2, 2026
| processor/deltatocumulativeprocessor/ @open-telemetry/collector-contrib-approvers @RichieSams | ||
| processor/deltatorateprocessor/ @open-telemetry/collector-contrib-approvers @Aneurysm9 | ||
| processor/dnslookupprocessor/ @open-telemetry/collector-contrib-approvers @andrzej-stencel @kaisecheng @edmocosta | ||
| processor/drainprocessor/ @open-telemetry/collector-contrib-approvers @MikeGoldsmith |
Contributor
Member
Author
There was a problem hiding this comment.
Thanks @edmocosta - I'll keep looking for other contributors who would be interested in supporting this component.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #47235
Overview
Adds
processor/drain, which applies the Drain log clustering algorithm to annotate log records with a derived template string.log.record.template"user <*> logged in from <*>"The processor annotates only — it does not filter. Use the
filterprocessor downstream to act on the template attribute.Key features
tree_depth,merge_threshold,max_node_children,max_clusters(LRU eviction)body_fieldextraction for structured (map) log bodiesseed_templatesorseed_logsfor stable templates across restartswarmup_min_clusters: trains from the first record but suppresses annotation until N distinct clusters are observed — records pass through immediately, no buffering or added latencyprocessor_drain_clusters_activegauge,processor_drain_log_records_annotatedandprocessor_drain_log_records_unannotatedcountersDependencies
This processor introduces one new third-party dependency:
github.com/Jaeyo/go-drain3go-drain3is a Go port of the Python Drain3 reference library. It was chosen for its complete implementation of the algorithm including JSON marshal/unmarshal hooks, which are the foundation for future snapshot persistence support.Test plan
go test -race ./...)golangci-lint run ./...)mdatagenChanges from initial proposal (post-SIG 2026-04-01)
jaeyo/go-drain3(was incorrectly listed asfaceair/drain)warmup_min_clustersintroduced as a zero-latency alternative: suppresses annotation during warmup without bufferinglog_cluster_depth→tree_depth,sim_threshold→merge_threshold,max_children→max_node_children— algorithm names referenced in docs