我需要有关如何通过ruby在过滤器下添加新字段的帮助,最后将其输出到文件中。 任何人都可以建议我吗?谢谢。
input {
file {
type => "syslog"
path => "/opt/logstash/log/dns.log"
start_position => beginning
sincedb_path => "/dev/null"
}
}
filter {
ruby {
code => "
if event['type'] == 'syslog'
event['newfield'] = 'NewInfoCreated'
end
"
}
}
output {
file {
path => "/opt/logstash/testing.txt"
codec => line { format => "custom format: %{message}"}
}
}
dns.log
的输入如下:
<blink>
{"ts":"2016-10 24T02:01:28.334052Z","uid":"CILq5k2MLCUYeBZJgd","id.orig_h":"10.17.103.224","id. orig_p":53362,"id.resp_h":"172.18.24.115"}
</blink>