Logstash基礎操作-input

獲取系統日誌,輸出至終端控制檯

./logstash -f ../config/logstash-1.conf 

input {
  file {
      path => ["/var/log/messages"]
      type => "system"
      start_position => "beginning"
   }
}
output {
 stdout {
    codec => rubydebug
  }
}

輸出信息中添加自定義字段,以便標識

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端口獲取網絡日誌

input {
   tcp {
   port => "5514"
   }
}
filter {
   grok {
   match => {"message" => "%{SYSLOGLINE}"}
   }
 }
output {
   stdout {
   codec => rubydebug
   }
}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章