Skip to content

Commit

Permalink
Add pattern to parse warnings from postfix/postmap
Browse files Browse the repository at this point in the history
  • Loading branch information
whyscream committed Jan 31, 2023
1 parent ab39dd3 commit 232fa22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 50-filter-postfix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ filter {
tag_on_failure => [ "_grok_postfix_virtual_nomatch" ]
add_tag => [ "_grok_postfix_success" ]
}
} else if [program] =~ /^postfix.*\/postmap$/ {
grok {
patterns_dir => "/etc/logstash/patterns.d"
match => [ "message", "^%{POSTFIX_POSTMAP}$" ]
tag_on_failure => [ "_grok_postfix_postmap_nomatch" ]
add_tag => [ "_grok_postfix_success" ]
}
} else if [program] =~ /^postfix.*/ {
mutate {
add_tag => [ "_grok_postfix_program_nomatch" ]
Expand Down
1 change: 1 addition & 0 deletions postfix.grok
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ POSTFIX_LOCAL %{POSTFIX_KEYVALUE}|%{POSTFIX_WARNING}
POSTFIX_VIRTUAL %{POSTFIX_SMTP_DELIVERY}
POSTFIX_ERROR %{POSTFIX_ERROR_ANY}
POSTFIX_POSTSUPER %{POSTFIX_POSTSUPER_ACTION}|%{POSTFIX_POSTSUPER_SUMMARY}
POSTFIX_POSTMAP %{POSTFIX_WARNING}
5 changes: 5 additions & 0 deletions test/postmap_0001.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pattern: ^%{POSTFIX_POSTMAP}$
data: "warning: /etc/postfix/conf.d/users.db: duplicate entry: \"[email protected]\""
results:
postfix_message_level: warning
postfix_message: "/etc/postfix/conf.d/users.db: duplicate entry: \"[email protected]\""

0 comments on commit 232fa22

Please sign in to comment.