-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
promtail: Add support for exclusion patterns in static_config
#5943
Conversation
if fi, err := os.Stat(t.pathExclude); err == nil && !fi.IsDir() { | ||
matchesExcluded = []string{t.pathExclude} | ||
} else { | ||
matchesExcluded, err = doublestar.Glob(t.pathExclude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If t.pathExclude is empty, then doublestar.Glob returns nil, nil
, just skipping the loop below.
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
This reverts commit 17abb006ce141071c4bca4b7d133bea2aa314594.
8a30ff2
to
838a8e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
is it please possible to make it exclude two files resp. two different logfiles with no common root (how about 3)? |
@adam0s9 hey there 👋 Right now this is not possible with the If you'd like to propose an enhancement to the way |
Signed-off-by: Paschalis Tsilias [email protected]
What this PR does / why we need it:
As stated in the linked Issue, there's currently no easy way to exclude files from a Promtail config, except for overly restrictive and/or complex glob patterns.
This addition may be helpful in a number of scenarios, from avoiding usage spikes in Grafana cloud, to having separate pipeline_stages for specific file formats, or filtering directories which Promtail couldn't tail due to permissions.
Since the upstream bmatcuk/doublestar package doesn't support negation patterns, this is another way of achieving the same result.
Which issue(s) this PR fixes:
Fixes #5744
Special notes for your reviewer:
From my local tests, this seems to work as intended both in scrape_config and file_sd_config blocks; let me know if I've missed anything ^^
Checklist
CHANGELOG.md
about the changes.