Filebeat学习记录

Filebeat学习笔记

是什么

日志收集工具,相当于轻量级的logstash

Filebeat配置

filebeat.inputs:    #定义数据的原型
- type: log      #指定数据类型
  enabled: true   #表明filebeat模块不生效,使用标准配置文件
  paths:   #指定监控的日志路径,可以是完整路径,也可以是模糊匹配
    - /var/log/*.log    
  fields:  # 表示新增一列,在filebeat输出日志中新增一列
    log_topic: osmessages
    apache: true
  fields_under_root: true
 
output.kafka:
  enabled: true
  hosts: ["192.16.1.20:9092", "192.168.1.30:9092", "192.168.1.40:9092"]
  topic: '%{[fields.log_topic]}' #指定filebeat要把日志输出到kafka的那个topic里
  partition.round_robin:   #ilebeat 提供多种输出至 kafka 分区的策略,包括 random,round_robin,hash,默认是 hash。上面的配置中,我们指定 round_robin(轮巡) 的策略
    reachable_only: true  #这表示仅将日志发布到可用分区
  worker: 2
  required_acks: 1  #指定kafka中的消息生产方式
  compression: gzip      # 消息压缩
  max_message_bytes: 1000000  #单条消息的最大长度
 logging.level: debug  #  设置日志级别
  
  
  • 启动
nohup ./filebeat -e -c filebeat.yml &

你可能感兴趣的:(Filebeat学习记录)