FileBeat安装(包含Windows和Linux)

FileBeat安装(包含Windows和Linux),第1张

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 &

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5653176.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存