1

我需要有关如何在过滤器下通过 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>
4

0 回答 0