14.基于kafka的日志收集
filebeat写入数据到kafka集群
1. 创建topic
1 | [root@elk01:5 ~]# kafka-topics.sh --bootstrap-server 10.0.0.212:9092 --topic linux-study --partitions 3 --replication-factor 2 --create |
2. filebeat写入数据到kafka
1 | [root@elk01:0 ~]# cat /etc/filebeat/20-filebeat-to-kafka.yaml |
3. kafka节点测试
1 | [root@elk01:0 ~]# kafka-console-consumer.sh --bootstrap-server 10.0.0.212:9092 --topic linux-study --from-beginning --group filebeat01 |
logstash从kafka集群读取数据
**1.编写logstash实例 **
1 | [root@elk01:0 ~]# cat /etc/logstash/conf.d/17-kafka-to-logstash.conf |
2. 启动logstash实例
1 | [root@elk01:0 ~]# logstash -rf /etc/logstash/conf.d/17-kafka-to-logstash.conf |
3. 优化logstash
1 | [root@elk01:0 ~]# cat /etc/logstash/conf.d/17-kafka-to-logstash.conf |
4. 正常操作优化,并输出到es集群
1 | [root@elk01:0 ~]# cat /etc/logstash/conf.d/17-kafka-to-logstash.conf |
评论