grippo 0.1.2

Parse, match and scrub data at scale.
Documentation
# Exim main log: `date [pid] msgid flag address key=value ...`. A message id is 6-6-2 characters, or 6-11-4 on hosts with large process ids.
EXIM_MSGID [0-9A-Za-z]{6}-(?:[0-9A-Za-z]{6}-[0-9A-Za-z]{2}|[0-9A-Za-z]{11}-[0-9A-Za-z]{4})
# Flags: arrival, normal delivery, additional address, cutthrough, suppressed, failed, deferred and fakereject.
EXIM_FLAGS (?:<=|[-=>*]>|\*\*|==|\(=)
EXIM_DATE %{YEAR:exim_year}-%{MONTHNUM:exim_month}-%{MONTHDAY:exim_day} %{TIME:exim_time}
EXIM_PID \[%{POSINT:pid}\]
# Queue time as in `QT=1h2m3s`.
EXIM_QT (?:[0-9]+y)?(?:[0-9]+w)?(?:[0-9]+d)?(?:[0-9]+h)?(?:[0-9]+m)?(?:[0-9]+s)?
EXIM_EXCLUDE_TERMS (?:Message is frozen|Start queue run|End queue run| Warning: | retry time not reached | no (?:IP address|host name) found for (?:IP address|host) | unexpected disconnection while reading SMTP command | no immediate delivery: |another process is handling this message)

# `H=[verified-name] [(helo-name)] [ip]:port`, `I=[ip]:port`, `P=protocol`, `S=size`, `id=message-id` and `T="subject"`.
EXIM_REMOTE_HOST H=(?:%{NOTSPACE:remote_hostname} )?(?:\(%{NOTSPACE:remote_heloname}\) )?\[%{IP:remote_host}\](?::%{POSINT:remote_port})?
EXIM_INTERFACE I=\[%{IP:exim_interface}\]:%{NUMBER:exim_interface_port}
EXIM_PROTOCOL P=%{NOTSPACE:protocol}
EXIM_MSG_SIZE S=%{NUMBER:exim_msg_size}
EXIM_HEADER_ID id=%{NOTSPACE:exim_header_id}
EXIM_SUBJECT T=%{QS:exim_subject}

# Any other item such as U=, A=, X= or QT=: one to four letters or digits, `=`, then a token.
EXIM_UNKNOWN_FIELD [A-Za-z0-9]{1,4}=%{NOTSPACE}
EXIM_NAMED_FIELDS (?: (?:%{EXIM_REMOTE_HOST}|%{EXIM_INTERFACE}|%{EXIM_PROTOCOL}|%{EXIM_MSG_SIZE}|%{EXIM_HEADER_ID}|%{EXIM_SUBJECT}|%{EXIM_UNKNOWN_FIELD}))*

# Arrival line. A bounce has the empty sender `<>`.
EXIM_MESSAGE_ARRIVAL %{EXIM_DATE:timestamp} (?:%{EXIM_PID} )?%{EXIM_MSGID:exim_msgid} (?<exim_flags><=) (?<exim_status>[a-z:] )?(?:<>|%{EMAILADDRESS:exim_sender_email})%{EXIM_NAMED_FIELDS}(?: for %{EMAILADDRESS:exim_recipient_email})?

EXIM %{EXIM_MESSAGE_ARRIVAL}