Hi Masahiro
Maybe I'm to stupid for regex?
I currently try to parse the mail log on the mailserver directly using tail like this:
<source>
@type tail
path /var/log/maillog
tag maillog
read_from_head = true
pos_file /root/fluentd/test.pos
format /^(?<time>[^ ]*\s*[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)(?:\[(?<ipa>([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}))\])?$/
</source>
Logs Entries come in like this:
Jun 2 13:22:29 mail postfix/smtpd[16604]: lost connection after AUTH from unknown[x.xxx.xxx.xxx]
Jun 2 13:22:29 mail postfix/smtpd[16604]: disconnect from unknown[x.xxxx.xxx.xxx]
Jun 2 13:22:29 mail postfix/smtpd[16604]: connect from unknown[x.xxxx.xxx.xxx]
But my regex doesn't work and I don't get an IPA: Field
.
On the other hand: how could I filter messages like:
Jun 2 13:22:29 mail postfix/smtpd[16604]: connect from unknown[x.xxxx.xxx.xxx]
*and*
Jun 2 13:22:48 mail postfix/smtpd[16604]: warning: unknown[x.xxxx.xxx.xxx]: SASL LOGIN authentication failed: authentication failure
Where ?<message> continues after the [?<ipa>] ?
Even if my regex worked, I'd cut the ?<message> at the IP and wouldn't continue.
thanks,
Andreas