Skip to content

Commit

Permalink
Add pattern to extract warnings from postfix-script loglines
Browse files Browse the repository at this point in the history
  • Loading branch information
whyscream committed Jan 31, 2023
1 parent 232fa22 commit 0529d69
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 @@ -168,6 +168,13 @@ filter {
tag_on_failure => [ "_grok_postfix_postmap_nomatch" ]
add_tag => [ "_grok_postfix_success" ]
}
} else if [program] =~ /^postfix.*\/postfix-script$/ {
grok {
patterns_dir => "/etc/logstash/patterns.d"
match => [ "message", "^%{POSTFIX_SCRIPT}$" ]
tag_on_failure => [ "_grok_postfix_script_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 @@ -138,3 +138,4 @@ POSTFIX_VIRTUAL %{POSTFIX_SMTP_DELIVERY}
POSTFIX_ERROR %{POSTFIX_ERROR_ANY}
POSTFIX_POSTSUPER %{POSTFIX_POSTSUPER_ACTION}|%{POSTFIX_POSTSUPER_SUMMARY}
POSTFIX_POSTMAP %{POSTFIX_WARNING}
POSTFIX_SCRIPT %{POSTFIX_WARNING}
5 changes: 5 additions & 0 deletions test/script_0001.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pattern: ^%{POSTFIX_SCRIPT}$
data: "warning: symlink leaves directory: /etc/postfix/./makedefs.out"
results:
postfix_message_level: warning
postfix_message: "symlink leaves directory: /etc/postfix/./makedefs.out"

0 comments on commit 0529d69

Please sign in to comment.