ruby过滤器内的ruby过滤器在=>时引发错误。我对如何使其发挥困惑感到困惑。我应该从具有许多json对象的日志文件中删除字段。我用很长的键删除条目。
input {
file {
type => "syslog"
# Wildcards work, here :)
path => ["C:\Users\ppurush\Desktop\test\*.log"]
}
}
filter{
ruby {
code =>"
keyval = [url][queryString].split('&')
for field in keyval
result = field.split(': ')
key = result[0]
if key =~ /^.{50,}$/
ruby {
remove_field =>"[ "[url][queryString]" ]"
}
end
"
}
}
output {
stdout { }
elasticsearch { embedded => true }
}
答案 0 :(得分:2)
ruby代码被双引号括起来,这意味着你不能在里面使用双引号 ruby代码本身。
另外,尝试捕捉错误:
ruby {
code => "
begin
# your great code goes here
rescue Exception => e
event['ruby_exception'] = 'YOUR_FILTER_NAME: ' + e.message
end
"
}