Skip to content

Commit 56e6ac7

Browse files
committed
Parse lines with client info where the ip-address is set to 'unknown'
Note that the value `unknown` is not saved to the ip address field, as this might mess up existing ip-address post-processing. To make the new possibility visible, a new field is added: `postfix_client_ip_unknown`.
1 parent 2289f26 commit 56e6ac7

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

postfix.grok

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Version: 1.0.0
22

3+
# helper patterns
4+
GREEDYDATA_NO_COLON [^:]*
5+
GREEDYDATA_NO_SEMICOLON [^;]*
6+
GREEDYDATA_NO_BRACKET [^<>]*
7+
STATUS_WORD [\w-]*
8+
IP_UNKNOWN unknown
9+
310
# common postfix patterns
411
POSTFIX_QUEUEID ([0-9A-F]{6,}|[0-9a-zA-Z]{12,}|NOQUEUE)
5-
POSTFIX_CLIENT_INFO %{HOSTNAME:postfix_client_hostname}?\[%{IP:postfix_client_ip}\](:%{INT:postfix_client_port})?
12+
13+
POSTFIX_CLIENT_INFO %{HOSTNAME:postfix_client_hostname}?\[(%{IP_UNKNOWN:postfix_client_ip_unknown}|%{IP:postfix_client_ip})\](:%{INT:postfix_client_port})?
614
POSTFIX_RELAY_INFO %{HOSTNAME:postfix_relay_hostname}?\[(%{IP:postfix_relay_ip}|%{DATA:postfix_relay_service})\](:%{INT:postfix_relay_port})?|%{WORD:postfix_relay_service}
715
POSTFIX_SMTP_STAGE (CONNECT|HELO|EHLO|STARTTLS|AUTH|MAIL( FROM)?|RCPT( TO)?|(end of )?DATA|RSET|UNKNOWN|END-OF-MESSAGE|VRFY|\.)
816
POSTFIX_ACTION (accept|defer|discard|filter|header-redirect|reject|reject_warning)
@@ -25,11 +33,6 @@ POSTFIX_LOSTCONN_REASONS (receiving the initial server greeting|sending message
2533
POSTFIX_PROXY_MESSAGE (%{POSTFIX_STATUS_CODE:postfix_proxy_status_code} )?(%{POSTFIX_STATUS_CODE_ENHANCED:postfix_proxy_status_code_enhanced})?.*
2634
POSTFIX_COMMAND_COUNTER_DATA (helo=(%{INT:postfix_cmd_helo_accepted}/)?%{INT:postfix_cmd_helo} )?(ehlo=(%{INT:postfix_cmd_ehlo_accepted}/)?%{INT:postfix_cmd_ehlo} )?(starttls=(%{INT:postfix_cmd_starttls_accepted}/)?%{INT:postfix_cmd_starttls} )?(auth=(%{INT:postfix_cmd_auth_accepted}/)?%{INT:postfix_cmd_auth} )?(mail=(%{INT:postfix_cmd_mail_accepted}/)?%{INT:postfix_cmd_mail} )?(rcpt=(%{INT:postfix_cmd_rcpt_accepted}/)?%{INT:postfix_cmd_rcpt} )?(data=(%{INT:postfix_cmd_data_accepted}/)?%{INT:postfix_cmd_data} )?(rset=(%{INT:postfix_cmd_rset_accepted}/)?%{INT:postfix_cmd_rset} )?(quit=(%{INT:postfix_cmd_quit_accepted}/)?%{INT:postfix_cmd_quit} )?(unknown=(%{INT:postfix_cmd_unknown_accepted}/)?%{INT:postfix_cmd_unknown} )?commands=(%{INT:postfix_cmd_count_accepted}/)?%{INT:postfix_cmd_count}
2735

28-
# helper patterns
29-
GREEDYDATA_NO_COLON [^:]*
30-
GREEDYDATA_NO_SEMICOLON [^;]*
31-
GREEDYDATA_NO_BRACKET [^<>]*
32-
STATUS_WORD [\w-]*
3336

3437
# warning patterns
3538
POSTFIX_WARNING_WITH_KV (%{POSTFIX_QUEUEID:postfix_queueid}: )?%{POSTFIX_WARNING_LEVEL:postfix_message_level}: (%{POSTFIX_QUEUEID:postfix_queueid}: )?(%{POSTFIX_CLIENT_INFO}: )?%{GREEDYDATA:postfix_message}; %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data}
@@ -87,9 +90,9 @@ POSTFIX_DNSBLOG_LISTING addr %{IP:postfix_client_ip} listed by domain %{HOSTNAME
8790
POSTFIX_TLSPROXY_CONN (DIS)?CONNECT( from)? %{POSTFIX_CLIENT_INFO}
8891

8992
# anvil patterns
90-
POSTFIX_ANVIL_CONN_RATE statistics: max connection rate %{NUMBER:postfix_anvil_conn_rate}/%{POSTFIX_TIME_UNIT:postfix_anvil_conn_period} for \(%{DATA:postfix_service}:%{IP:postfix_client_ip}\) at %{SYSLOGTIMESTAMP:postfix_anvil_timestamp}
93+
POSTFIX_ANVIL_CONN_RATE statistics: max connection rate %{NUMBER:postfix_anvil_conn_rate}/%{POSTFIX_TIME_UNIT:postfix_anvil_conn_period} for \(%{DATA:postfix_service}:(%{IP_UNKNOWN:postfix_client_ip_unknown}|%{IP:postfix_client_ip})\) at %{SYSLOGTIMESTAMP:postfix_anvil_timestamp}
9194
POSTFIX_ANVIL_CONN_CACHE statistics: max cache size %{NUMBER:postfix_anvil_cache_size} at %{SYSLOGTIMESTAMP:postfix_anvil_timestamp}
92-
POSTFIX_ANVIL_CONN_COUNT statistics: max connection count %{NUMBER:postfix_anvil_conn_count} for \(%{DATA:postfix_service}:%{IP:postfix_client_ip}\) at %{SYSLOGTIMESTAMP:postfix_anvil_timestamp}
95+
POSTFIX_ANVIL_CONN_COUNT statistics: max connection count %{NUMBER:postfix_anvil_conn_count} for \(%{DATA:postfix_service}:(%{IP_UNKNOWN:postfix_client_ip_unknown}|%{IP:postfix_client_ip})\) at %{SYSLOGTIMESTAMP:postfix_anvil_timestamp}
9396

9497
# smtp patterns
9598
POSTFIX_SMTP_DELIVERY %{POSTFIX_KEYVALUE} status=%{STATUS_WORD:postfix_status}( \(%{GREEDYDATA:postfix_smtp_response}\))?

test/anvil_0008.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pattern: ^%{POSTFIX_ANVIL}$
2+
data: "statistics: max connection count 1 for (smtp:unknown) at Sep 7 07:14:19"
3+
results:
4+
postfix_anvil_conn_count: 1
5+
postfix_service: smtp
6+
postfix_client_ip_unknown: unknown
7+
postfix_anvil_timestamp: Sep 7 07:14:19

test/anvil_0009.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pattern: ^%{POSTFIX_ANVIL}$
2+
data: "statistics: max connection rate 1/60s for (smtp:unknown) at Sep 7 07:14:19"
3+
results:
4+
postfix_anvil_conn_rate: 1
5+
postfix_anvil_conn_period: 60s
6+
postfix_service: smtp
7+
postfix_client_ip_unknown: unknown
8+
postfix_anvil_timestamp: Sep 7 07:14:19

test/smtpd_0032.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pattern: ^%{POSTFIX_SMTPD}$
2+
data: "disconnect from unknown[unknown] commands=0/0"
3+
results:
4+
postfix_client_hostname: unknown
5+
postfix_client_ip_unknown: unknown
6+
postfix_command_counter_data: commands=0/0
7+

0 commit comments

Comments
 (0)