摘要:我有一些出站 smtp 服务器,并通过 rsyslog 将邮件日志集中到我正在使用 logstash 的服务器上,输出到 elasticsearch,使用 kibana 进行搜索。
我想将后缀邮件日志条目标记为"退回",例如:
2013-02-01T16:50:14+02:00 XXSMTPXX postfix/smtp[10879]: BC54A65BD4: to=<xxxx.yyyyyy@zzzz.com.t>, relay=none, delay=0.3, delays=0.01/0/0.29/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=gozdesigorta.com.t type=AAAA: Host not found)
我在 logstash.conf 中使用的 grok 过滤器是这样的:
grok {
patterns_dir => "/etc/logstash/patterns"
tags => "postfix/bounce"
pattern => "%{POSTFIXBOUNCE}"
add_tag => "BOUNCED"
named_captures_only => true
}
我正在使用的模式文件 https://gist.github.com/4691822
我无法设法将这些日志行标记为退回...我错过了什么?
我将模式更改为:
%{TIMESTAMP_ISO8601} %{HOST} %{SYSLOGPROG}: %{QUEUEID}: to=<%{EMAILADDRESS:to}>, relay=%{RELAY}, delay=%{POSREAL:delay}, delays=%{DELAYS}, dsn=%{DSN}, status=%{STATUS} %{GREEDYDATA:reason}
现在我可以摸索;)
你能粘贴完整的logstash.conf吗?我收到以下错误:
Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [ \t\r\n], "#", "=>" at line 20, column 19 (byte 558) after filter { n grok {n patterns_dir => "/etc/logstash/conf.d/patterns"n tags => "postfix/bounce"n pattern => "%{POSTFIXBOUNCE}"n add_tag => "%{TIMESTAMP_ISO8601} %{HOST} %{SYSLOGPROG}: %{QUEUEID}: to=<%{EMAILADDRESS:to}>, relay=%{RELAY}, delay=%{POSREAL:delay}, delays=%{DELAYS}, dsn=%{DSN}, status=%{STATUS} %{GREEDYDATA:reason}"n named_captures_only => truen }nnoutput {n elasticsearch ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:32:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:189:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:72:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:47:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:383:in `block in converge_state'"]}