Skip to content

feat(loki.enrich): Add multi-label matching - #7053

Open
efadeev wants to merge 1 commit into
grafana:mainfrom
efadeev:feat/loki-enrich-multi-label-matching
Open

efadeev wants to merge 1 commit into
grafana:mainfrom
efadeev:feat/loki-enrich-multi-label-matching

Conversation

@efadeev

@efadeev efadeev commented Sep 8, 2026

Copy link
Copy Markdown

Brief description of Pull Request

Add multi-label matching to loki.enrich through the new target_to_log_match argument. The argument maps discovered target labels to incoming log labels. All configured label pairs must match the same target before its labels are copied to the log entry.

Keep the deprecated target_match_label and logs_match_label arguments for compatibility, with target_to_log_match taking precedence when both mechanisms are configured.

Extract target matching into a shared library used by both loki.enrich and prometheus.enrich. Update the component documentation and example configuration.

Pull Request Details

The shared matcher handles label ordering, value hashing, and target lookup. Target label names are sorted before constructing lookup keys, making matching deterministic regardless of map iteration order.

Targets with missing or empty match labels are excluded from the lookup. Log entries with missing or empty match labels are forwarded unchanged. Each component retains its existing label-copying behavior and synchronization.

Tests cover multi-label matching, missing and empty labels, duplicate targets, value boundaries, target snapshots, legacy compatibility, and validation. Tests for the shared matcher and both enrichment components pass with -race after rebasing onto main.

Previous PR.

Issue(s) fixed by this Pull Request

Fixes #7009

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated
  • This pull request was substantially generated with AI assistance (see the GenAI policy)

@efadeev
efadeev requested review from a team and clayton-cornell as code owners September 8, 2026 13:20
@kalleep

kalleep commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

For the future, don't close and open up a new pr but instead change in the pr you already created. Now this one will not have the comment I added to the other one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multi-label matching on loki.enrich

2 participants