filebeat 采集日志送Kafka

下载并解压filebeat

tar xf filebeat-7.7.0-linux-x86_64.tar.gz
mv filebeat-7.7.0-linux-x86_64 filebeat-7.7.0

新建配置文件

vim kafka_log.yml

filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - /data/logs/*.log
output.kafka:
  hosts:
    - 192.168.2.129:9092
    - 192.168.2.130:9092
  topic: data_log

启动filebeat

cd filebeat-7.7.0
./filebeat -e -c kafka_log.yml
# 启动到后台
nohup ./filebeat -e -c kafka_log.yml &> /dev/null &
# 添加到crontab
*/5 * * * * if [ -z $(ps -ef | grep filebeat | grep -v grep) ];then /app/filebeat-7.7.0/filebeat -e -c /app/filebeat-7.7.0/kafka_log.yml &> /dev/null & fi
posted @ 2020-06-30 12:31  Peterer~王勇  阅读(374)  评论(0编辑  收藏  举报