When containers are sending their logs to journald, how to set journalmatch to a string instead of a service? #3704
-
I have several containers sending logs to journald with a prefix so I can differentiate them: Here are examples of the log:
I am trying to get each jail to look only at their related logs by using its prefix string. So far, I have tried to set journalmatch in my jail.local like this:
But I am not sure if it works. I tried doing a manual test and the result is no lines are found from the log. Perhaps my command line is wrong as I could not find details about this in the documents I read. I tried those, also replaced the " with an asterisk *: fail2ban-regex --journalmatch=MESSAGE="container/dovecot" systemd-journal[journalflags=1] dovecot
1- Any help on how to properly set journalmatch or something that would work with the journald logs? 2- Are there any tools or tips to test that all jails are working since there are so many. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Beta Was this translation helpful? Give feedback.
container/postfix/smtp/smtpd[...]
is called UNIT in journal fields. To check what exactly you can use, you need to inspect the output ofjournalctl -o json-pretty
and then use it withjournalmatch
.smtp/smtpd[...]
but gotcontainer/postfix/smtp/smtpd[...]
it would not match.So you have to filter by filter they still work, or to rewrite parts of them or overwrite certain parameters like
_daemon
, like here:fail2ban/config/filter.d/postfix.conf
Line 13 in b59fd2e