【发布时间】:2017-06-29 08:38:58
【问题描述】:
我有以下 logstash 配置:
input { stdin { } }
output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
}
filter {
ruby {
code => "
@@exists_pattern = ['foo', 'bar'].any?{ |pattern| event.get('message').include?(pattern) }
event.add('keep_line', @@exists_pattern)
"
}
if not [keep_line] { drop { } }
grok {
match => {
"message" => '%{IP:serverip} \[%{HTTPDATE:my_timestamp}\]'
}
}
date {
match => [ "my_timestamp", "dd/MMM/YYYY:HH:mm:ss Z"]
target => "@timestamp"
}
}
但是当我尝试使用这个配置文件运行 logstash 时,我得到了这个错误:
[ERROR][logstash.agent] Cannot create pipeline {:reason=>"Expected one of #, ( at line 30, column 10 (byte 923) after filter {\n # grok...
如何在 if 指令中使用 ruby 代码块 (event['keep_line']) 中设置的变量?
【问题讨论】:
标签: logstash logstash-configuration