-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Submission type
- Request for enhancement (RFE)
systemd version the issue has been seen with
234
Used distribution
irrelevant
Description
A possibility to filter logs in journald, i.e., before they are written to the journal, would be helpful in cases where some daemon spams the log with countless messages.
Of course, it is better to fix the source instead of filtering away log messages, but for many users the former is not possible and the latter is a helpful workaround until the real problem is fixed.
As an example, my concrete current problem is that I need to run snmpd for lack of alternatives and it spams the log with error messages (so just reducing the log level would mean I also do not see other errors), and this behavior exists for years but is not getting fixed (Debian bug from 2015, Red Hat bug from 2016). This shows that in practice, a log-filter possibility would indeed be helpful.
I know that journalctl can filter log messages, but for cases like this I do not want these messages to be written to the journal, because for example many such messages can lead to earlier-than-desired log truncation due to the SystemMaxUse/SystemKeepFree options.
rsyslog has an equivalent feature (which I have been using until now), so I could solve this by ignoring the journal and using traditional syslog, but I really like the additional features of the journal and do not want to fall back to syslog just because of this.
I do not have a full proposal how the syntax for log filters could look like. I suggest to start with an option in journald.conf that can take an expression similar to that of journalctl, but I assume that for such a feature to be most useful there would need to be the possibility to due regexp or at least substring matches on the message field, like rsyslog has. Maybe a syntax inspired by CSS attribute selectors could be used or something like Perl-style =~ for regexp matches?