CentOS安装filebeat收集日志到kafka,


简介

filebeat是日志数据采集器,可代替logstash收集日志,部署起来比较方便。

一般日志量比较大,会先收集到kafka然后再进行消费。

安装

  1. yum -y install https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/7.14.0/filebeat-7.14.0-x86_64.rpm 
CentOS安装filebeat收集日志到kafka

配置filebeat

  1. vim /etc/filebeat/filebeat.yml 
  1. filebeat.inputs: 
  2. - type: log 
  3.   paths: 
  4.     - /var/log/*.log 
  5.     - /var/log/messages 
  6.   fields: 
  7.     type: "systemlog" 
  8.     log_topic: "systemlog" 
  9.   fields_under_root: true 
  10.   exclude_lines: ["^DBG"] 
  11.   exclude_files: [".gz$"] 
  12. name: 192.168.122.100 
  13. output.kafka: 
  14.   enabled: true 
  15.   hosts: ["192.168.122.200:9092"] 
  16.   topic: "%{[log_topic]}" 
  17.   partition.round_robin: 
  18.     reachable_only: true 
  19.   worker: 2 
  20.   required_acks: 1 
  21.   compression: gzip 
  22.   max_message_bytes: 10000000 

服务管理

  1. systemctl enable filebeat 
  2. systemctl start filebeat 

总结

filebeat是Go写的,部署起来很方便,没什么依赖,批量部署简单。

相关内容