输入命令测试:
bin/logstash -f logstash.conf
示例1:
logstash配置文件,从终端读取内容,然后从终端上显示出来
input {
stdin {add_field => {"key" => "value"}
codec => "plain"
tags => ["add"]
type => "std"
}
}
output
{stdout
{codec=>rubydebug}
}
示例2:从文件夹读取文件,然后再终端上显示
input {
file {
path => ["/home/gaoweiapp/*.txt"]
type => "system"
start_position => "beginning"
}
}
output
{
stdout
{codec=>rubydebug}
}
示例3:从文件夹读取文件,传送至kafka集群
input {
file {
path => ["/home/gaoweiapp/*.txt"]
type => "system"
start_position => "beginning"
}
}
output
{
kafka {
codec => plain {
format => "%{message}"
}
bootstrap_servers => "127.0.0.1:9092,127.0.0.23:9092"
topic_id => "test"
}
}