LogStash Note

将logs目录下的所有log文件发送至Kafka

环境信息

logstash version 6.0.1
kafka 192.168.1.2:9002
kafka topic myapplog
log目录 /MyApp/logs/

logstash config

1
2
3
4
5
6
7
8
9
10
11
12
13
input {
file {
path => "/MyApp/logs/*.log"
start_position => "beginning"
}
}
output {
kafka {
bootstrap_servers => "192.168.1.2:9092"
topic_id => "myapplog"
compression_type => "gzip" # string (optional), one of ["none", "gzip", "snappy"], default: "none"
}
}

运行logstash

1
logstash -f apiweblogstash.conf

测试

监听myapplog主题并查看消息

1
kafkacat -C -b 192.168.1.2:9092 -t myapplog