[英]Ruby plugin in logstash not working
The ruby filter inside ruby filter raises an error at =>. 红宝石过滤器内部的红宝石过滤器在=>处引发错误。 I'm confused on how to make it work.
我对如何使其工作感到困惑。 I am supposed to remove fields from log files which has many json objects.
我应该从具有许多json对象的日志文件中删除字段。 I am removing the entries with very long keys.
我正在删除具有很长键的条目。
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 }
}
The ruby code is surrounded by double quotes, which means you can't use double quotes inside the ruby code itself. 红宝石代码被双引号包围,这意味着您不能在红宝石代码本身内部使用双引号。
Also, try catching errors: 另外,尝试捕获错误:
ruby {
code => "
begin
# your great code goes here
rescue Exception => e
event['ruby_exception'] = 'YOUR_FILTER_NAME: ' + e.message
end
"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.