Repository navigation
Allow for journald logs filtering on a per-unit basis - #24058
Merged
Merged
Conversation
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.
Implement mechanism to filter logs ingested by journald using regexes (#6432).
Implement for two new keywords in unit files (in
Servicesection):LogIncludeRegex=LogExcludeRegex=When journald will process logs on a unit with
LogIncludeRegexdefined, it will continue processing if the log message matches the regex, and discard it if it doesn't. The opposite behaviour is used forLogExcludeRegex. If none is defined, then all log messages are processed as usual. If both are defined, then the log message must matchLogIncludeRegexbut notLogExcludeRegexto be processed.flowchart TD A{{Is LogIncludeRegex defined?}} B{{Does LogIncludeRegex matches?}} C{{Is LogExcludeRegex defined?}} D{{Does LogExcludeRegex matches?}} F>Discard log] E>Ingest log] style A fill:#f5f3f4,stroke:#219ebc,stroke-width:3px style B fill:#f5f3f4,stroke:#219ebc,stroke-width:3px style C fill:#f5f3f4,stroke:#219ebc,stroke-width:3px style D fill:#f5f3f4,stroke:#219ebc,stroke-width:3px style E fill:#f5f3f4,stroke:#219ebc,stroke-width:3px style F fill:#f5f3f4,stroke:#219ebc,stroke-width:3px A -- YES --> B -- YES --> C -- YES --> D A -- NO --> C B -- NO --> F C -- NO --> E D -- NO --> E D -- YES --> FBoth regexes are read from the unit file (or from D-Bus or
systemctl set-property) and stored within the unit's cgroup xattr for journald to read.Changes in this PR have been tested using
mkosi qemu. Sending logs to journald usinglogger,systemd-catandStandardOutput=journal. This change is feature complete, I will add a last commit to update integration tests.Based on #25394