feat: support log line content filtering via RELABEL_CONFIGS#98
Open
Omerlustig wants to merge 4 commits into
Open
feat: support log line content filtering via RELABEL_CONFIGS#98Omerlustig wants to merge 4 commits into
Omerlustig wants to merge 4 commits into
Conversation
|
|
jeschkies
reviewed
Mar 25, 2026
jeschkies
left a comment
Contributor
There was a problem hiding this comment.
I'm wondering if we should rather support Promtail stages https://grafana.com/docs/loki/latest/send-data/promtail/stages/
299a023 to
5a8cb01
Compare
Omerlustig
pushed a commit
to Omerlustig/lambda-promtail
that referenced
this pull request
Jun 13, 2026
Salvage the relabel Sort() bug fix, drop the redundant __log_line__ feature in favor of native Promtail drop stages, and make stage-based filtering deployable via a new loki_stage_configs Terraform var. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Reworked per review feedback:
Will sign the CLA. |
applyRelabelConfigs carried the comment "Sort labels as required by Process" but never called Sort(). Add the call so the code matches the comment and stays correct under stringlabels builds (Loki's default), where Labels.Get does a sorted binary search. No-op under this repo's default slicelabels build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The code already reads LOKI_STAGE_CONFIGS but it was not settable via Terraform. Plumb it through so deploys can configure Promtail pipeline stages (e.g. a drop stage) to filter log lines by content. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5a8cb01 to
b55ed54
Compare
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.
Summary
RELABEL_CONFIGSto filter log entries based on log line content using a synthetic__log_line__label, allowing users to drop noisy lines (e.g.END RequestId:) before they are sent to Loki__log_line__label is injected temporarily before relabeling and stripped afterwards so it never reaches LokiScratchBuilder.Sort()was missing beforerelabel.Process, which uses binary search internally and produced non-deterministic results on unsorted labelsHow it works
Users can now use the existing
RELABEL_CONFIGSenv var withsource_labels: ["__log_line__"]to match against log line content:[{"source_labels":["__log_line__"],"regex":"END RequestId:.*","action":"drop"}]All Prometheus relabel actions (
drop,keep,replace,labeldrop, etc.) are supported. Existing label-only relabel configs continue to work unchanged.Test plan
TestBatchAddDropsLogLinesViaRelabelConfig— drop action on log line contentTestBatchAddKeepsEntriesWithNoRelabelConfig— no-op when no configs setTestBatchAddKeepActionFiltersLogLines— keep action filteringTestBatchAddLogLineLabelNotInOutput—__log_line__label never in outputTestBatchAddLabelOnlyRelabelStillWorks— backward compat with label-only relabelTestBatchAddDropMultiplePatterns— multi-pattern drop🤖 Generated with Claude Code