From 9dae6c7ec887456a9abd44a13acc33511ce2085d Mon Sep 17 00:00:00 2001 From: Evgenii Fadeev Date: Fri, 28 Aug 2026 22:04:02 +0300 Subject: [PATCH] feat(loki.enrich): Add multi-label matching --- .../reference/components/loki/loki.enrich.md | 86 ++++++---- internal/component/common/enrich/matcher.go | 88 ++++++++++ .../component/common/enrich/matcher_test.go | 158 ++++++++++++++++++ internal/component/loki/enrich/enrich.go | 95 ++++++----- internal/component/loki/enrich/enrich_test.go | 155 +++++++++++++++++ .../component/prometheus/enrich/enrich.go | 94 +---------- 6 files changed, 524 insertions(+), 152 deletions(-) create mode 100644 internal/component/common/enrich/matcher.go create mode 100644 internal/component/common/enrich/matcher_test.go diff --git a/docs/sources/reference/components/loki/loki.enrich.md b/docs/sources/reference/components/loki/loki.enrich.md index 8d74924c31e..fcc4a8b5a9f 100644 --- a/docs/sources/reference/components/loki/loki.enrich.md +++ b/docs/sources/reference/components/loki/loki.enrich.md @@ -15,25 +15,33 @@ description: The loki.enrich component enriches logs with labels from service di {{< docs/shared lookup="stability/experimental.md" source="alloy" version="" >}} The `loki.enrich` component enriches logs with additional labels from service discovery targets. -It matches a label from incoming logs against a label from discovered targets, and copies specified labels from the matched target to the log entry. +It matches labels from incoming logs against labels from discovered targets, and copies specified labels from the matched target to the log entry. +If no match occurs, the component forwards the log entry unchanged. + +Use the `target_to_log_match` argument to specify which target labels correspond to which log labels. +The map keys are target label names and the values are the corresponding log label names. +All labels in the map must match for enrichment to occur. + +{{< admonition type="warning" >}} +The `target_match_label` and `logs_match_label` arguments are deprecated in favor of `target_to_log_match`. +If `target_to_log_match` is set, it takes precedence. +Replace `target_match_label = "hostname"` with `target_to_log_match = {"hostname" = "hostname"}`. +These deprecated arguments will be removed in a future release. +{{< /admonition >}} ## Usage ```alloy loki.enrich "