FileBeat安装(包含Windows和Linux)

Windows版本

第一步

下载安装包。
下载地址:https://www.elastic.co/cn/downloads/beats/filebeat

第二步

解压安装包。并配置【filebeat.yml】文件。
注:具体支持的输出方式可以参考官网:https://www.elastic.co/guide/en/beats/filebeat/current/configuring-output.html
以日期开头合并的多行:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - G:/log/*.log
  multiline:
    #正则,以日期开头的合并多行
    pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
    negate: true
   match: after
   max_lines: 1000
   timeout: 3s
output.elasticsearch:
  hosts: ["127.0.0.1:9200"]
  index: "actionlog-%{+yyyy.MM}"
setup.template.name: "actionlog"
setup.template.pattern: "actionlog-*"
setup.ilm.enabled: false

以<数字>开头合并多行:

filebeat.inputs:
- type: log
  #是否开启配置,此处需要设置true
  enabled: true
  #监控目录
  paths:
    - G:/log/*.log
  multiline:
    pattern: '^<[0-9]+'
    negate: true
    match: after
    timeout: 10s
#输出ES
output.elasticsearch:
  hosts: ["127.0.0.1:9200"]
  index: "actionlog-%{+yyyy.MM}"
setup.template.name: "actionlog"
setup.template.pattern: "actionlog-*"
setup.ilm.enabled: false

优化文件只读取一次,1分钟不更新就关闭监控的方案:

filebeat.inputs:
- type: log
  #是否开启配置,此处需要设置true
  enabled: true
  # 检查文件更新的频率
  # 默认是 10s
  scan_frequency: 10s
  #只读取一次文件,读取完成之后,关闭收割机
  close_eof: true
  # 如果一个文件在某个时间段内没有发生过更新则关闭监控的文件handle。默认1h,change只会在下一次scan才会被发现
  close_older: 1m
  #即当文件名称有变化时,包括改名和删除,会自动关闭一个文件
  force_close_files: true
  #监控目录
  paths:
    - G:/log/*.log
  multiline:
    pattern: '^<[0-9]+'
    negate: true
    match: after
    timeout: 10s
#输出ES
output.elasticsearch:
  hosts: ["127.0.0.1:9200"]
  index: "actionlog-%{+yyyy.MM}"
setup.template.name: "actionlog"
setup.template.pattern: "actionlog-*"
setup.ilm.enabled: false

以<数字>开头合并多行并输出的KafKa:

filebeat.inputs:
- type: log
  #是否开启配置,此处需要设置true
  enabled: true
  # 检查文件更新的频率
  # 默认是 10s
  scan_frequency: 10s
  #只读取一次文件,读取完成之后,关闭收割机
  close_eof: true
  # 如果一个文件在某个时间段内没有发生过更新则关闭监控的文件handle。默认1h,change只会在下一次scan才会被发现
  close_older: 1m
  #即当文件名称有变化时,包括改名和删除,会自动关闭一个文件
  force_close_files: true
  #监控目录
  paths:
    - /monitor/log/*.log
  multiline:
    pattern: '^<[0-9]+'
    negate: true
    match: after
    timeout: 10s
#输出KafKa
output.kafka:
  hosts: ["localhost:9092"]
  topic: hillstonelog
  keep_alive: 10s

第三步

启动fileBeat。需要用cmd窗口启动。
.\filebeat -e -c filebeat.yml

Linux版本

第一步

下载安装包。
下载地址:https://www.elastic.co/cn/downloads/beats/filebeat

第二步

将压缩包上传到指定目录并解压
tar -zxvf filebeat-7.14.1-linux-x86_64.tar.gz

第三步

配置【filebeat.yml】文件。
注:具体支持的输出方式可以参考官网:https://www.elastic.co/guide/en/beats/filebeat/current/configuring-output.html

第四步

启动fileBeat。

./filebeat -e -c filebeat.yml

#后台启动

nohup ./filebeat -e -c filebeat.yml > /dev/null 2>&1 &
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

铁蛋的铁,铁蛋的蛋

留一杯咖啡钱给作者吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值