Here is my config, and works well in 2.2
.
cat /etc/logstash/conf.d/logstash.conf
input {
redis {
data_type => "list"
batch_count => 50
host => "127.0.0.1"
key => "logstash"
password => "mypasswd"
}
}
filter {
if ! [type] or ! [tags] {
drop { }
}
if [host] !~ "rtdstest.*" and "throttled" not in [tags] and (
(
[loglevel] == "ERROR" and
"未知采集器" not in [message] and
"数据上报帧里的sid为空" not in [message] and
"没有对应的Sampler" not in [message] and
"Connection reset by peer" not in [message]
) or
[loglevel] != "ERROR" and
"Exception" in [message]
) {
mutate {
add_tag => [ "alert" ]
add_field => { "mailto" => "myemail@email.com"}
}
if "找不到对应的iid信息" in [message] or
"未配置功率计算规则!" in [message] {
mutate {
update => {
"mailto" => "myemail@email.com"
}
}
}
}
}
output {
elasticsearch {
hosts => "127.0.0.1"
}
if "alert" in [tags] {
email {
address => "smtp.exmail.qq.com"
authentication => "login"
username => "username"
password => "password"
to => "%{mailto}"
from => "Logstash<logstash@mydomain.com>"
body => "%{message}"
subject => "服务器 %{host} %{type} 日志发现异常, LOGLEVEL-%{loglevel}: %{content}"
}
}
if "slow_query" in [tags] and
[duration] >= 10000 {
email {
address => "smtp.exmail.qq.com"
authentication => "login"
username => "username"
password => "password"
to => "to@mydomain.com"
from => "Logstash<logstash@mydomain.com>"
body => "%{message}"
subject => "服务器 %{host} %{type} 日志发现慢查询, query耗时: %{duration} ms"
}
}
}
But when I upgrade to 2.3
, will raise this error:
/opt/logstash/bin/logstash -f /etc/logstash/conf.d/logstash.conf -t
An unexpected error occurred! {:error=>#<NoMethodError: undefined method `config_valid?' for LogStash::Pipeline:Class>, :class=>"NoMethodError", :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.0-java/lib/logstash/agent.rb:169:in `execute'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.0-java/lib/logstash/runner.rb:94:in `run'", "org/jruby/RubyProc.java:281:in `call'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.0-java/lib/logstash/runner.rb:99:in `run'", "org/jruby/RubyProc.java:281:in `call'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.22/lib/stud/task.rb:24:in `initialize'"], :level=>:warn}
My OS is ubuntu 14.04, and java version is 1.8.0_77
.