logstash配置(一)
警告
本文最后更新于 2020-05-30 17:09,文中内容可能已过时。
1.命令行运行一个简单的输入输出
./logstash -e 'input{stdin{}} output{stdout{codec=>rubydebug}}'

将上面的配置写到配置文件中,以配置文件的方式加载
vim test.conf
input {
stdin{}
}
output{
stdout{codec => rubydebug}
}
./logstash -f test.conf
2.使用文件的方式收集日志
input {
file{
path => "/var/log/messages"
}
}
output{
stdout{codec => rubydebug}
}
./logstash -f test.conf
新建一个终端链接查看是否有日志输出

2.1 将日志输出到kafka中
./logstash -f test.conf
input {
file{
path => "/var/log/messages"
}
}
output{
kafka{
bootstrap_servers => "log1:9092"
topic_id => "test_kafka"
}
}
连接kafka消费端,新建终端看看效果

后台方式运行logstash
nohup ./logstash -f test.conf &> logstash.log &
请我喝杯水

