Logstash基础操做-input

获取系统日志,输出至终端控制台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
   }
}
相关文章
相关标签/搜索