獲取系統日誌,輸出至終端控制檯ruby
./logstash -f ../config/logstash-1.conf input { file { path => ["/var/log/messages"] type => "system" start_position => "beginning" } } output { stdout { codec => rubydebug } }
輸出信息中添加自定義字段,以便標識bash
input { stdin { add_field => {"key" => "iivey" } tags => ["add1"] type => "test1" } } output { stdout { codec => rubydebug } }
獲取指定主機的rSyslog 日誌網絡
配置logstash 配置文件並啓動: input { syslog { port => "5514" } } output { stdout { codec => rubydebug } } 修改指定主機的rSyslog 輸出地址並重啓rSyslog服務 vi /etc/rsyslog.conf # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional #*.* @@remote-host:514 # ### end of the forwarding rule ### *.* @@10.10.23.43:5514
經過TCP端口獲取網絡日誌tcp
input { tcp { port => "5514" } } filter { grok { match => {"message" => "%{SYSLOGLINE}"} } } output { stdout { codec => rubydebug } }