FileBeat是一个日志收集器,基于Logstash-Forwarder的源代码。FileBeat通常以代理的身份运行在客户端服务器中,并监视用户指定的目录、文件,同时把日志文件更新部分推送给Logstash解析或者直接推送给ES索引。服务器
FileBeat的工做方式:
当FileBeat在服务器上启动后,它同时启动一个或者多个prospectors
来监视用户指定的日志文件目录。
prospectors
而后针对每一个日志文件,都启动一个harvester
,每个harvester
监视一个文件的新增内容,并把新增内容送到spooler
中。而后spooler
来汇总这些events
事件。而后把这些事件传送给logstash或者es。elasticsearch
FileBeat的使用与ES、Logstash基本同样,从官方网站下载*.tar.gz
文件,而后解压。添加配置文件,而后就能够运行了。ide
若是用rpm或者deb的安装包,配置文件的位置在:
/etc/filebeat/filebeat.yml
。fetch
下面是一个默认的配置文件:网站
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
, 可选的类型有log
和stdin
。
document_type
会在日志的输出中增长一个type
的字段。若是输入的对象是es
,那么这个字段就是es
中文档的类型
。this
在设置日志文件的路径时,每个prospector
监视一个路径(目录)。代理