FileBeat

FileBeat使用说明

FileBeat是一个日志收集器,基于Logstash-Forwarder的源代码。FileBeat一般以代理的身份运行在客户端服务器中,并监视用户指定的目录、文件,同时把日志文件更新部分推送给Logstash解析或者直接推送给ES索引。

Alt text

FileBeat的工作方式:
当FileBeat在服务器上启动后,它同时启动一个或者多个prospectors来监视用户指定的日志文件目录。
prospectors然后针对每个日志文件,都启动一个harvester,每一个harvester监视一个文件的新增内容,并把新增内容送到spooler中。然后spooler来汇总这些events事件。然后把这些事件传送给logstash或者es。

一、 FileBeat的安装配置

1. FileBeat的通用配置

FileBeat的使用与ES、Logstash基本一样,从官方网站下载*.tar.gz文件,然后解压。添加配置文件,然后就可以运行了。

如果用rpm或者deb的安装包,配置文件的位置在:/etc/filebeat/filebeat.yml

下面是一个默认的配置文件:

filebeat:
  # List of prospectors to fetch data.
  prospectors:
    # Each - is a prospector. Below are the prospector specific configurations
    -
      # Paths that should be crawled and fetched. Glob based paths.
      # For each file found under this path, a harvester is started.
      paths:
        - "/var/log/*.log"
        #- c:\programdata\elasticsearch\logs\*

      # Type of the files. Based on this the way the file is read is decided.
      # The different types cannot be mixed in one prospector
      #
      # Possible options are:
      # * log: Reads every line of the log file (default)
      # * stdin: Reads the standard in
      input_type: log
      
      # Type to be published in the 'type' field. For Elasticsearch output,
	  # the type defines the document type these entries should be stored
	  # in. Default: log
	  document_type: syslog
......

input_type 决定了被监听文件的读取方式,同一个prospector不能混用不同的input_type, 可选的类型有logstdin
document_type 会在日志的输出中增加一个type的字段。如果输入的对象是es,那么这个字段就是es中文档的类型

在设置日志文件的路径时,每一个prospector监视一个路径(目录)。

posted @ 2016-11-18 12:18  stemon  阅读(771)  评论(0编辑  收藏  举报