Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filter {
- ### general
- mutate { remove_field => ["host"] }
- if "beats_input_codec_plain_applied" in [tags] {
- mutate { remove_tag => ["beats_input_codec_plain_applied"] }
- }
- ### mailbox.log
- if [log][file][path] == "/opt/zimbra/log/mailbox.log" {
- grok {
- match => { 'message' => "^%{TIMESTAMP_ISO8601:logtime} %{LOGLEVEL:loglevel}[[:space:]]*%{GREEDYDATA:message}$" }
- overwrite => ["message"]
- }
- date {
- match => [ "logtime", "yyyy-MM-dd HH:mm:ss,SSS" ]
- target => "@timestamp"
- locale => "en_US"
- tag_on_failure => ["date_filter_failed"]
- }
- mutate { add_tag => [ "zimbra" ] }
- ### message count
- if "smtp - Sending message to" in [message] {
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_1
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};mid=[\d]*;oip=%{IP:oip};(port=[\d]*;)*ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*).*Message-ID=<(?<messageid>[\w$\.\@\-]*)>,.*sender=%{ZIMBRA_USER:sender}, nrcpts=(?<nrcpts>[\d]*),.*" }
- #mailbox.log_2
- match => { 'message' => "^\[LmtpServer-[\d]*\] \[name=%{ZIMBRA_USER};mid=[\d]*;ip=%{IP};\] smtp - Sending message to MTA at %{IPORHOST}.*Message-ID=<(?<messageid>[\w$\.\@\-]*)>,.*sender=%{ZIMBRA_USER:sender}, nrcpts=(?<nrcpts>[\d]*),.*" }
- #mailbox.log_18
- match => { 'message' => "^\[ScheduledTask-[\d]*\] \[\] smtp - Sending message to MTA at %{IPORHOST}.*Message-ID=<(?<messageid>[\w$\.\@\-]*)>,.*sender=%{ZIMBRA_USER:sender}, nrcpts=(?<nrcpts>[\d]*),.*$" }
- #mailbox.log_19
- match => { 'message' => "^\[ScheduledTask-[\d]*\] \[name=%{ZIMBRA_USER};mid=[\d]*;ds=[\w\-]*;\] smtp - Sending message to MTA at %{IPORHOST}.*Message-ID=<(?<messageid>[\w$\.\@\-]*)>, origMsgId=[\w\-:]*, replyType=[\w], .*sender=%{ZIMBRA_USER:sender}, nrcpts=(?<nrcpts>[\d]*),.*$" }
- remove_tag => [ "_grokparsefailure"]
- }
- mutate {
- add_tag => [ "message_sent" ]
- convert => { "nrcpts" => "integer" }
- }
- } ### message count
- ### authentication failed
- if "authentication failed" in [message] {
- mutate { add_tag => [ "authentication_failed" ] }
- if "invalid password" in [message] {
- mutate { add_tag => [ "invalid_password" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_3
- match => { 'message' => "^\[[\w\d\-\]]* \[ip=%{IP};(oip|ip)=%{IP:oip};via=.*;ua=%{ZIMBRA_CLIENT:client};cid=[\d]*;\] imap - authentication failed for \[%{ZIMBRA_USER:account}] \(invalid password\)$" }
- #mailbox.log_4
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};oport=[\d]*;oproto=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*).*%{ZIMBRA_SOAP_HANDLER} \[%{ZIMBRA_USER}\], invalid password$" }
- #mailbox.log_5
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);\].*%{ZIMBRA_SOAP_HANDLER} \[" }
- #mailbox.log_6
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};port=[\d]*;ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);\].*%{ZIMBRA_SOAP_HANDLER} \[%{ZIMBRA_USER}\], invalid password$" }
- remove_tag => [ "_grokparsefailure"]
- }
- }
- if "status is locked" in [message] {
- mutate {
- add_tag => [ "locked_attempts" ]
- }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_7
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip}.*oproto=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*).*%{ZIMBRA_SOAP_HANDLER} \[.*status is locked$" }
- remove_tag => ["_grokparsefailure"]
- }
- }
- if "account not found" in [message] {
- mutate { add_tag => [ "account_not_found" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log.8
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[(oip|ip)=%{IP:oip}.*oproto=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);] SoapEngine - handler exception: authentication failed for \[%{ZIMBRA_USER}\], account not found$" }
- #mailbox.log_9
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[(oip|ip)=%{IP:oip};ua=%{ZIMBRA_CLIENT:client};soapId(?<soapid>[^;]*);] %{ZIMBRA_SOAP_HANDLER} \[%{ZIMBRA_USER:account}], account not found$" }
- remove_tag => [ "_grokparsefailure"]
- }
- }
- if "account lockout" in [message] {
- mutate { add_tag => [ "locked_account" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_10
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=(?<account>[^;]+);(oip|ip)=%{IP:oip};ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);].*?((?<reason>(?=account lockout).*).*)?$" }
- #mailbox.log_11
- match => { 'message' => "^\[name=(?<validated_account>[^;]*);oip=%{IP:oip}.*oproto=(?<protocol>[^;]*).*soapId=(?<soapid>[^;]*).*\[(?<account>[^\]]*).*account lockout" }
- match => { 'message' => "^\[ImapSSLServer-[\d]*\] \[ip=%{IP:ip};oip=%{IP:oip}.*ua=[^ ]* (imap) - authentication failed for \[%{ZIMBRA_USER:account}\].* \((?<reason>account lockout)\)?$" }
- remove_tag => [ "_grokparsefailure"]
- }
- }
- if "status is closed" in [message] {
- mutate { add_tag => [ "account_closed" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_12
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};oport=[\d]*;oproto=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);\].*%{ZIMBRA_SOAP_HANDLER} \[(%{ZIMBRA_USER}|[\w]*)\], account\(or domain\) status is closed$" }
- remove_tag => [ "_grokparsefailure"]
- }
- }
- } ### authentication failed
- ### dos filter triggered
- if "suspended, for repeated failed login" in [message] {
- mutate { add_tag => ["suspended_ip"] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_13
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP}[\s\[\]\w\-]*misc - Access from IP *%{IP:oip} suspended, for repeated failed login\.$" }
- remove_tag => [ "_grokparsefailure"]
- }
- } ### dos filter triggered
- ### overquota warnings
- if "LmtpServer" in [message] and "Over quota" in [message] {
- mutate { add_tag => ["over_quota"] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_14
- match => { 'message' => "^\[LmtpServer\-(?<lmtpserver_id>[\d]*)\]\s*\[name=(?<account>[^;]*).*" }
- remove_tag => [ "_grokparsefailure"]
- }
- } ### overquota warnings
- ### purge operations
- if "MailboxPurge" in [message] {
- mutate { add_tag => ["mailbox_purge"] }
- if "Deleting Message" in [message] {
- mutate { add_tag => ["purging_message"] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_15
- match => { 'message' => "^\[MailboxPurge\] \[name=(?<account>[^;]*)" }
- remove_tag => [ "_grokparsefailure"]
- }
- }
- } ### purge operations
- ### delegated auths
- if "DelegateAuth" in [message] and "delegated access" in [message] {
- mutate { add_tag => ["delegated_access"] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_16
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};port=[\d]*;ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*).*authenticated account=(?<authenticated_account>[^,]*).*target account=(?<target_account>[^;]*)$" }
- #mailbox.log_20
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(aname=%{ZIMBRA_USER:aname})?mid=[\d]*;(oip|ip)=%{IP:oip};port=[\d]*;ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*).*authenticated account=(?<authenticated_account>[^,]*).*target account=(?<target_account>[^;]*)$" }
- remove_tag => [ "_grokparsefailure"]
- }
- } ### delegated auths
- ### spam reports
- if "Junk-NotJunk-Handler" in [message] {
- mutate { add_tag => ["spam_reporting"] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- #mailbox.log_17
- match => { 'message' => "^\[Junk-NotJunk-Handler].*account=%{ZIMBRA_USER:account}.*isSpam=(?<spam>(true|false))" }
- remove_tag => [ "_grokparsefailure"]
- }
- } ### spam reports
- } ### mailbox.log
- ### audit.log
- if [log][file][path] == "/opt/zimbra/log/audit.log" {
- grok {
- match => { 'message' => "^%{TIMESTAMP_ISO8601:logtime} %{LOGLEVEL:loglevel}[[:space:]]*%{GREEDYDATA:message}$" }
- overwrite => ["message"]
- }
- date {
- match => [ "logtime", "yyyy-MM-dd HH:mm:ss,SSS" ]
- target => "@timestamp"
- locale => "en_US"
- tag_on_failure => ["date_filter_failed"]
- }
- mutate { add_tag => [ "zimbra" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- add_tag => ["authentication_success"]
- #audit.log 1
- match => { 'message' => "^%{ZIMBRA_MAILBOX_ID_SOAP} \[name=%{ZIMBRA_USER:account};(oip|ip)=%{IP:oip};ua=%{ZIMBRA_CLIENT:client};soapId=(?<soapid>[^;]*);\] security - cmd=(Auth|AdminAuth); account=%{ZIMBRA_USER}; protocol=[\w]*;$" }
- }
- } ### audit.log
- ### zimbra.log
- if [log][file][path] == "/var/log/zimbra.log" {
- grok {
- match => { 'message' => "^%{SYSLOGTIMESTAMP:logtime}\s%{IPORHOST:hostname}[[:space:]]*%{GREEDYDATA:message}$" }
- overwrite => ["message"]
- }
- date {
- match => [ "logtime", "MMM dd HH:mm:ss", "MMM d HH:mm:ss" ]
- target => "@timestamp"
- locale => "en_US"
- tag_on_failure => ["date_filter_failed"]
- }
- mutate { add_tag => [ "zimbra" ] }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- add_tag => ["spam"]
- #zimbra.log 1
- match => { 'message' => "^amavis\[[\d]*\]: \([\d\-]*\) [\w\-]*, <%{EMAILADDRESS:sender}> -> <%{EMAILADDRESS:rcpt}>, (?<isspam>(Yes|No)), score=(?<spamscore>[\d\.]*) required=[\d\.]* tests=\[(?<tests>[^]]*)\] autolearn=(yes|no|disabled) autolearn_force=(yes|no|disabled)$" }
- }
- grok {
- patterns_dir => ["/etc/logstash/patterns"]
- add_tag => ["virus"]
- #zimbra.log 2
- match => { 'message' => "^amavis\[[\d]*\]: \([\d\-]*\) (?<virus>Blocked INFECTED) \((?<signature>[\w\._\-]*)\) {DiscardedInbound,Quarantined}, \[%{IPORHOST}\]:[\d]* \[%{IPORHOST:ip}\] <(?<sender>%{EMAILADDRESS})> -> <(?<rcpt>%{EMAILADDRESS})>, quarantine: %{EMAILADDRESS}, Queue-ID: [\w]*, Message-ID: <[^>]*>, mail_id: (?<mailid>[\w]*), Hits: [\w,\-:\s]* ms$" }
- }
- } ### zimbra.log
- # general geoip
- if ("" in [oip]) {
- geoip { source => "oip" }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement