journal: log filtering options support in PID1
Define new unit parameter (LogFilterPatterns) to filter logs processed by journald. This option is used to store a regular expression which is carried from PID1 to systemd-journald through a cgroup xattrs: `user.journald_log_filter_patterns`.
This commit is contained in:
@@ -2919,6 +2919,34 @@ StandardInputData=V2XigLJyZSBubyBzdHJhbmdlcnMgdG8gbG92ZQpZb3Uga25vdyB0aGUgcnVsZX
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>LogFilterPatterns=</varname></term>
|
||||
|
||||
<listitem><para>Define an extended regular expression to filter log messages based on the
|
||||
<varname>MESSAGE=</varname> field of the structured message. If the first character of the pattern is
|
||||
<literal>~</literal>, log entries matching the pattern should be discarded. This option takes a single
|
||||
pattern as an argument but can be used multiple times to create a list of allowed and denied patterns.
|
||||
If the empty string is assigned, the filter is reset, and all prior assignments will have no effect.</para>
|
||||
|
||||
<para>Because the <literal>~</literal> character is used to define denied patterns, it must be replaced
|
||||
with <literal>\x7e</literal> to allow a message starting with <literal>~</literal>. For example,
|
||||
<literal>~foobar</literal> would add a pattern matching <literal>foobar</literal> to the deny list, while
|
||||
<literal>\x7efoobar</literal> would add a pattern matching <literal>~foobar</literal> to the allow list.</para>
|
||||
|
||||
<para>Log messages are tested against denied patterns (if any), then against allowed patterns
|
||||
(if any). If a log message matches any of the denied patterns, it will be discarded, whatever the
|
||||
allowed patterns. Then, remaining log messages are tested against allowed patterns. Messages matching
|
||||
against none of the allowed pattern are discarded. If no allowed patterns are defined, then all
|
||||
messages are processed directly after going through denied filters.</para>
|
||||
|
||||
<para>Filtering is based on the unit for which <varname>LogFilterPatterns=</varname> is defined, meaning log
|
||||
messages coming from
|
||||
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> about the
|
||||
unit are not taken into account. Filtered log messages won't be forwarded to traditional syslog daemons,
|
||||
the kernel log buffer (kmsg), the systemd console, or sent as wall messages to all logged-in
|
||||
users.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>LogNamespace=</varname></term>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user