有用的链接:

https://www.cnblogs.com/cjsblog/p/9445792.html

安装Filebeat

  1. brew install filebeat

Filebeat 的配置文件

配置文件包含: fields.yml filebeat.docker.yml filebeat.reference.yml filebeat.yml modules.d

  1. cd /usr/local/etc/filebeat

FileBeat 基础知识

image.png
Beats是用于单用途数据托运人的平台。它们以轻量级代理的形式安装,并将来自成百上千台机器的数据发送到Logstash或Elasticsearch。
(画外音:通俗地理解,就是采集数据,并上报到Logstash或Elasticsearch)
Beats对于收集数据非常有用。它们位于你的服务器上,将数据集中在Elasticsearch中,Beats也可以发送到Logstash来进行转换和解析。为了捕捉(捕获)数据,Elastic提供了各种Beats:
image.png

Beats可以直接(或者通过Logstash)将数据发送到Elasticsearch,在那里你可以进一步处理和增强数据,然后在Kibana中将其可视化:
image.png

FileBeat 配置日志采集和输出地址

修改 Filebeat.yml 文件

  1. #=========================== Filebeat inputs ==============
  2. filebeat.inputs:
  3. - type: log
  4. enabled: true
  5. paths:
  6. - /var/log/*.log
  7. #============================== Dashboards ===============
  8. setup.dashboards.enabled: false
  9. #============================== Kibana ==================
  10. setup.kibana:
  11. host: "192.168.101.5:5601"
  12. #-------------------------- Elasticsearch output ---------
  13. output.elasticsearch:
  14. hosts: ["localhost:9200"]

注:Filebeat 默认加载fileds.yml 索引模版。 可以修改 filebeat.yml 文件来加载不同的模版:

  1. 加载不同模版

    setup.template.name: "your_template_name"
    setup.template.fields: "path/to/fields.yml"
    
  2. 覆盖一个已存在的模版:

    setup.template.overwrite: true
    
  3. 默认模版是自动加载的,可以禁用自动加载模版:

    setup.template.enabled: false
    
  4. 修改索引名称

    # 默认情况下,Filebeat写事件到名为filebeat-6.3.2-yyyy.MM.dd的索引,其中yyyy.MM.dd是事件被索引的日期。为了用一个不同的名字,你可以在Elasticsearch输出中设置index选项。例如:
    output.elasticsearch.index: "customname-%{[beat.version]}-%{+yyyy.MM.dd}"
    setup.template.name: "customname"
    setup.template.pattern: "customname-*"
    setup.dashboards.index: "customname-*"
    
  5. 手动加载模版:

    ./filebeat setup --template -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["localhost:9200"]'
    
  6. 设置dashboard

     ./filebeat setup --dashboards
    
  7. 启动filebeat

    ./filebeat -e -c filebeat.yml -d "publish"
    

Filebeat 详细配置

工作原理(input 与 harverset) 与 模块化配置
https://segmentfault.com/a/1190000016591944
https://www.cnblogs.com/cjsblog/p/9495024.html
https://juejin.cn/post/6959743971870375966