使用logstash tcp插件,监听某个tcp端口

1.编辑logstash配置文件

[root@elk log]# cat /etc/logstash/conf.d/tcp.conf 
input {
    tcp {
        host => "192.168.1.22"
        port => "6666"
    }

}

output {
    stdout {
        codec => "rubydebug"
    }

}

2.启动测试

[root@elk conf.d]# /usr/share/logstash/bin/logstash -f tcp.conf 

## 使用nc工具向6666端口发出文本
[root@elk log]# echo "test"| nc 192.168.1.22 6666
[root@elk conf.d]# /usr/share/logstash/bin/logstash -f tcp.conf 
## logstash 输出
{
      "@version" => "1",
       "message" => "test",
    "@timestamp" => 2019-01-23T02:27:43.870Z,
          "host" => "elk",
          "port" => 51489
}

results matching ""

    No results matching ""