From c1da84034c617352e40fe514498bc297d41866e7 Mon Sep 17 00:00:00 2001 From: hyili Date: Tue, 28 Nov 2017 17:50:57 +0800 Subject: [PATCH] add support for status recognition --- postfix.grok | 11 ++++++----- test/error_0002.yaml | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 test/error_0002.yaml diff --git a/postfix.grok b/postfix.grok index 703a80f..63a656d 100644 --- a/postfix.grok +++ b/postfix.grok @@ -24,6 +24,7 @@ POSTFIX_COMMAND_COUNTER_DATA (helo=(%{INT:postfix_cmd_helo_accepted}/)?%{INT:pos # helper patterns GREEDYDATA_NO_COLON [^:]* GREEDYDATA_NO_SEMICOLON [^;]* +STATUS_WORD [\w-]* # warning patterns POSTFIX_WARNING_WITH_KV (%{POSTFIX_QUEUEID:postfix_queueid}: )?%{POSTFIX_WARNING_LEVEL:postfix_message_level}: %{GREEDYDATA:postfix_message}; %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data} @@ -44,16 +45,16 @@ POSTFIX_CLEANUP_MILTER %{POSTFIX_QUEUEID:postfix_queueid}: milter-%{POSTFIX_ACTI # qmgr patterns POSTFIX_QMGR_REMOVED %{POSTFIX_QUEUEID:postfix_queueid}: removed POSTFIX_QMGR_ACTIVE %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data} \(queue active\) -POSTFIX_QMGR_EXPIRED %{POSTFIX_QUEUEID:postfix_queueid}: from=<%{DATA:postfix_from}>, status=%{WORD:postfix_status}, returned to sender +POSTFIX_QMGR_EXPIRED %{POSTFIX_QUEUEID:postfix_queueid}: from=<%{DATA:postfix_from}>, status=%{STATUS_WORD:postfix_status}, returned to sender # pipe patterns -POSTFIX_PIPE_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data}, status=%{WORD:postfix_status} \(%{GREEDYDATA:postfix_pipe_response}\) +POSTFIX_PIPE_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data}, status=%{STATUS_WORD:postfix_status} \(%{GREEDYDATA:postfix_pipe_response}\) # error patterns -POSTFIX_ERROR_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data}, status=%{WORD:postfix_status} \(%{GREEDYDATA:postfix_error_response}\) +POSTFIX_ERROR_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data}, status=%{STATUS_WORD:postfix_status} \(%{GREEDYDATA:postfix_error_response}\) # discard patterns -POSTFIX_DISCARD_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data} status=%{WORD:postfix_status} %{GREEDYDATA} +POSTFIX_DISCARD_ANY %{POSTFIX_QUEUEID:postfix_queueid}: %{POSTFIX_KEYVALUE_DATA:postfix_keyvalue_data} status=%{STATUS_WORD:postfix_status} %{GREEDYDATA} # postsuper patterns POSTFIX_POSTSUPER_ACTIONS (removed|requeued|placed on hold|released from hold) @@ -82,7 +83,7 @@ POSTFIX_ANVIL_CONN_CACHE statistics: max cache size %{NUMBER:postfix_anvil_cache 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} # smtp patterns -POSTFIX_SMTP_DELIVERY %{POSTFIX_KEYVALUE} status=%{WORD:postfix_status}( \(%{GREEDYDATA:postfix_smtp_response}\))? +POSTFIX_SMTP_DELIVERY %{POSTFIX_KEYVALUE} status=%{STATUS_WORD:postfix_status}( \(%{GREEDYDATA:postfix_smtp_response}\))? POSTFIX_SMTP_CONNERR connect to %{POSTFIX_RELAY_INFO}: (Connection timed out|No route to host|Connection refused|Network is unreachable) 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})? POSTFIX_SMTP_TIMEOUT %{POSTFIX_QUEUEID:postfix_queueid}: conversation with %{POSTFIX_RELAY_INFO} timed out( while %{POSTFIX_LOSTCONN_REASONS:postfix_smtp_lostconn_reason})? diff --git a/test/error_0002.yaml b/test/error_0002.yaml new file mode 100644 index 0000000..b62d99d --- /dev/null +++ b/test/error_0002.yaml @@ -0,0 +1,7 @@ +pattern: ^%{POSTFIX_ERROR}$ +data: "3E29030F8637E: to=, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.1.1, status=undeliverable-but-not-cached (User unknown in virtual alias table)" +results: + postfix_queueid: "3E29030F8637E" + postfix_keyvalue_data: "to=, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.1.1" + postfix_status: undeliverable-but-not-cached + postfix_error_response: "User unknown in virtual alias table"