我发送几个日志logstash中央服务器使用另一个客户端logstash托运人。 inputtypes是“文件”。 邮件在服务器上收到,但它不反映客户端的IP地址。 它会在“@source_host”字段中发送主机名。 有什么我可以做的IP作为一个领域? 也许filter?
客户端conf:
input { file { format => "plain" path => "/var/log/app/test1.txt" type => "start" } } output { redis { host => "test.example.com" data_type => "list" key => "logstash" } }
您可以使用“dns”filter进行反向查找,然后使用它来设置字段。 http://logstash.net/docs/1.2.2/filters/dns
如果你想要的客户端IP是静态的,那么我build议你可以使用mutatefilterreplace内容@source_host
例如:
filter { mutate { replace => ["@source_host","xx.xx.xx.xx"] } }
如果你只是想在一个字段(而不是@source_host)的IP,你可以添加它在你的input:
input { file { format => "plain" path => "/var/log/app/test1.txt" type => "start" add_field => ['source_ip','xx.xx.xx.xx'] } }
否则,如果你真的需要parsing非静态的客户端主机名,那么@ 丹Garthwaite的答案是正确的。