Skip to content

Commit 7e9a0ce

Browse files
authored
Merge pull request #174 from whyscream/168-new-patterns
New patterns from #168
2 parents 80eae92 + 0529d69 commit 7e9a0ce

File tree

8 files changed

+39
-3
lines changed

8 files changed

+39
-3
lines changed

50-filter-postfix.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ filter {
161161
tag_on_failure => [ "_grok_postfix_virtual_nomatch" ]
162162
add_tag => [ "_grok_postfix_success" ]
163163
}
164+
} else if [program] =~ /^postfix.*\/postmap$/ {
165+
grok {
166+
patterns_dir => "/etc/logstash/patterns.d"
167+
match => [ "message", "^%{POSTFIX_POSTMAP}$" ]
168+
tag_on_failure => [ "_grok_postfix_postmap_nomatch" ]
169+
add_tag => [ "_grok_postfix_success" ]
170+
}
171+
} else if [program] =~ /^postfix.*\/postfix-script$/ {
172+
grok {
173+
patterns_dir => "/etc/logstash/patterns.d"
174+
match => [ "message", "^%{POSTFIX_SCRIPT}$" ]
175+
tag_on_failure => [ "_grok_postfix_script_nomatch" ]
176+
add_tag => [ "_grok_postfix_success" ]
177+
}
164178
} else if [program] =~ /^postfix.*/ {
165179
mutate {
166180
add_tag => [ "_grok_postfix_program_nomatch" ]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Contributing
4949

5050
I only have access to my own log samples, and my setup does not support or use every feature in postfix. If you miss anything, please open a pull request on github. If you're not very well versed in regular expressions, it's also fine to only submit sample unsupported log lines.
5151

52+
Other guidelines:
53+
- There is no goal to parse every possible Postfix log line. The goal is to extract useful data from the logs in a generic way.
54+
- The target for data extraction is logging from a local server. There have been requests to parse SMTP replies from remote (Postfix) servers that are logged by the SMTP client (`postfix/smtp` program name). There is no way to parse these replies in a generic way, they differ from implementation to implementation (f.i. Postfix vs Exim) and from server to server (every admin can customize the message format). Parsing stock replies from remote Postfix servers could be done, but would be confusing since the messages don't originate from the local server. Requests for parsing these are not honoured. If you like to do that, implement it yourself, or start a separate project, I'd be happy to add a link to it. :)
55+
5256
License
5357
-------
5458

postfix.grok

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ POSTFIX_SMTP_SSLCONNERR SSL_connect error to %{POSTFIX_RELAY_INFO}: %{POSTFIX_LO
9797
POSTFIX_SMTP_LOSTCONN %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_LOSTCONN:postfix_smtp_lostconn_data} with %{POSTFIX_RELAY_INFO}( while %{POSTFIX_LOSTCONN_REASONS:postfix_smtp_lostconn_reason})?
9898
POSTFIX_SMTP_TIMEOUT %{POSTFIX_QUEUEID:postfix_queueid}: conversation with %{POSTFIX_RELAY_INFO} timed out( while %{POSTFIX_LOSTCONN_REASONS:postfix_smtp_lostconn_reason})?
9999
POSTFIX_SMTP_RELAYERR %{POSTFIX_QUEUEID:postfix_queueid}: host %{POSTFIX_RELAY_INFO} said: %{GREEDYDATA:postfix_smtp_response} \(in reply to %{POSTFIX_SMTP_STAGE:postfix_smtp_stage} command\)
100+
POSTFIX_SMTP_SSLAUTHERR %{POSTFIX_QUEUEID:postfix_queueid}: SASL authentication failed; server %{POSTFIX_RELAY_INFO} said: %{GREEDYDATA:postfix_smtp_response}
100101
POSTFIX_SMTP_UTF8 host %{POSTFIX_RELAY_INFO} offers SMTPUTF8 support, but not 8BITMIME
101102
POSTFIX_SMTP_PIX %{POSTFIX_QUEUEID:postfix_queueid}: enabling PIX workarounds: %{DATA:postfix_pix_workaround} for %{POSTFIX_RELAY_INFO}
102103

@@ -120,7 +121,7 @@ POSTFIX_PIPE %{POSTFIX_PIPE_ANY}
120121
POSTFIX_POSTSCREEN %{POSTFIX_PS_CONNECT}|%{POSTFIX_PS_ACCESS}|%{POSTFIX_PS_NOQUEUE}|%{POSTFIX_PS_TOOBUSY}|%{POSTFIX_PS_CACHE}|%{POSTFIX_PS_DNSBL}|%{POSTFIX_PS_VIOLATIONS}|%{POSTFIX_WARNING}
121122
POSTFIX_DNSBLOG %{POSTFIX_DNSBLOG_LISTING}|%{POSTFIX_WARNING}
122123
POSTFIX_ANVIL %{POSTFIX_ANVIL_CONN_RATE}|%{POSTFIX_ANVIL_CONN_CACHE}|%{POSTFIX_ANVIL_CONN_COUNT}
123-
POSTFIX_SMTP %{POSTFIX_SMTP_DELIVERY}|%{POSTFIX_SMTP_CONNERR}|%{POSTFIX_SMTP_SSLCONNERR}|%{POSTFIX_SMTP_LOSTCONN}|%{POSTFIX_SMTP_TIMEOUT}|%{POSTFIX_SMTP_RELAYERR}|%{POSTFIX_TLSCONN}|%{POSTFIX_WARNING}|%{POSTFIX_SMTP_UTF8}|%{POSTFIX_TLSVERIFICATION}|%{POSTFIX_SMTP_PIX}
124+
POSTFIX_SMTP %{POSTFIX_SMTP_DELIVERY}|%{POSTFIX_SMTP_CONNERR}|%{POSTFIX_SMTP_SSLCONNERR}|%{POSTFIX_SMTP_SSLAUTHERR}|%{POSTFIX_SMTP_LOSTCONN}|%{POSTFIX_SMTP_TIMEOUT}|%{POSTFIX_SMTP_RELAYERR}|%{POSTFIX_TLSCONN}|%{POSTFIX_WARNING}|%{POSTFIX_SMTP_UTF8}|%{POSTFIX_TLSVERIFICATION}|%{POSTFIX_SMTP_PIX}
124125
POSTFIX_DISCARD %{POSTFIX_DISCARD_ANY}|%{POSTFIX_WARNING}
125126
POSTFIX_LMTP %{POSTFIX_SMTP}
126127
POSTFIX_PICKUP %{POSTFIX_KEYVALUE}
@@ -136,3 +137,5 @@ POSTFIX_LOCAL %{POSTFIX_KEYVALUE}|%{POSTFIX_WARNING}
136137
POSTFIX_VIRTUAL %{POSTFIX_SMTP_DELIVERY}
137138
POSTFIX_ERROR %{POSTFIX_ERROR_ANY}
138139
POSTFIX_POSTSUPER %{POSTFIX_POSTSUPER_ACTION}|%{POSTFIX_POSTSUPER_SUMMARY}
140+
POSTFIX_POSTMAP %{POSTFIX_WARNING}
141+
POSTFIX_SCRIPT %{POSTFIX_WARNING}

test/command_counter_data_0003.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
pattern: ^%{POSTFIX_COMMAND_COUNTER_DATA}
32
data: helo=1 mail=2 rcpt=1 data=1 rset=1 quit=1 commands=7
43
results:

test/command_counter_data_0004.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
pattern: ^%{POSTFIX_COMMAND_COUNTER_DATA}
32
data: helo=1 quit=1 unknown=0/2 commands=2/4
43
results:

test/postmap_0001.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pattern: ^%{POSTFIX_POSTMAP}$
2+
data: "warning: /etc/postfix/conf.d/users.db: duplicate entry: \"xxx@yyy.com\""
3+
results:
4+
postfix_message_level: warning
5+
postfix_message: "/etc/postfix/conf.d/users.db: duplicate entry: \"xxx@yyy.com\""

test/script_0001.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pattern: ^%{POSTFIX_SCRIPT}$
2+
data: "warning: symlink leaves directory: /etc/postfix/./makedefs.out"
3+
results:
4+
postfix_message_level: warning
5+
postfix_message: "symlink leaves directory: /etc/postfix/./makedefs.out"

test/smtp_0032.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pattern: "^%{POSTFIX_SMTP}$"
2+
data: "D0F29603B4: SASL authentication failed; server xyz.example.com[1.2.3.4] said: 535 5.7.8 Error: authentication failed: authentication failure"
3+
results:
4+
postfix_queueid: D0F29603B4
5+
postfix_relay_hostname: xyz.example.com
6+
postfix_relay_ip: 1.2.3.4
7+
postfix_smtp_response: "535 5.7.8 Error: authentication failed: authentication failure"

0 commit comments

Comments
 (0)