From 2dfac72835daa7ec7706bdb1828db4e16ae33eb9 Mon Sep 17 00:00:00 2001 From: Karsten Jeschkies Date: Thu, 13 Jul 2023 09:48:15 +0200 Subject: [PATCH] Clarify that label filter expressions are not supported in promtail. (#9894) **What this PR does / why we need it**: Some users of Promtail seem to be confused that certain types of filter expressions are not supported in Promtail's `match` stage. This change clarifies what kind of filter expressions are supported. **Which issue(s) this PR fixes**: Fixes #5209 **Special notes for your reviewer**: **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [x] Documentation added - [ ] Tests updated - [ ] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](https://github.com/grafana/loki/commit/d10549e3ece02120974929894ee333d07755d213) --------- Co-authored-by: J Stickler --- clients/pkg/logentry/stages/match_test.go | 1 + docs/sources/clients/promtail/stages/match.md | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/clients/pkg/logentry/stages/match_test.go b/clients/pkg/logentry/stages/match_test.go index ebaf7d5a9f..558407320c 100644 --- a/clients/pkg/logentry/stages/match_test.go +++ b/clients/pkg/logentry/stages/match_test.go @@ -126,6 +126,7 @@ func TestMatcher(t *testing.T) { {`{foo="bar",bar!~"te.*"}`, map[string]string{"foo": "bar", "bar": "test"}, MatchActionDrop, false, false, false}, {`{foo=""}`, map[string]string{}, MatchActionKeep, false, true, false}, + {`{foo="bar"} |= "foo" | status >= 200`, map[string]string{"foo": "bar"}, MatchActionKeep, false, false, true}, } for _, tt := range tests { diff --git a/docs/sources/clients/promtail/stages/match.md b/docs/sources/clients/promtail/stages/match.md index 4ae2aa5b1b..50dd06aed8 100644 --- a/docs/sources/clients/promtail/stages/match.md +++ b/docs/sources/clients/promtail/stages/match.md @@ -5,14 +5,19 @@ description: match stage # match The match stage is a filtering stage that conditionally applies a set of stages -or drop entries when a log entry matches a configurable [LogQL]({{< relref "../../../query" >}}) -stream selector and filter expressions. +or drop entries when a log entry matches a configurable LogQL +[stream selector]({{< relref "../../../query/log_queries#log-stream-selector" >}}) and +[filter expressions]({{< relref "../../../query/log_queries#line-filter-expression" >}}). + +{{% admonition type="note" %}} +The filters do not include label filter expressions such as `| label == "foobar"`. +{{% /admonition %}} ## Schema ```yaml match: - # LogQL stream selector and filter expressions. + # LogQL stream selector and line filter expressions. selector: # Names the pipeline. When defined, creates an additional label in