Filebeat 详细配置


 Filebeat 配置文件中文对照
###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.
    # 指定文件的输入类型log(默认)或者stdin
- type: log

# 更改为 true 以启用此配置。
enabled: false

#应该爬网和提取的路径
paths:
- /var/log/*.log

# 指定被监控的文件的编码类型,使用plain和utf-8都是可以处理中文日志的
  encoding: plain

# 排除行, 要匹配的正则表达式的列表. 它将从列表中删除与任何正则表达式匹配的行.
#exclude_lines: ['^DBG']

# 包含行. 要匹配的正则表达式的列表. 它从列表中导出与任何正则表达式匹配的行.
#include_lines: ['^ERR', '^WARN']

# 排除文件. 要匹配的正则表达式的列表。 Filebeat 将从列表中删除与任何正则表达式匹配的文件。默认情况下, 不会删除任何文件。
#exclude_files: ['.gz$']

# 向输出的每一条日志添加额外的信息,比如“level:debug”,方便后续对日志进行分组统计。
# 默认情况下,会在输出信息的fields子目录下以指定的新增fields建立子目录,例如fields.level
# 这个得意思就是会在es中多添加一个字段,格式为 "filelds":{"level":"debug"}
#fields:
# level: debug
# review: 1

# 如果该选项设置为true,则新增fields成为顶级目录,而不是将其放在fields目录下。
# 自定义的field会覆盖filebeat默认的field
# 如果设置为true,则在es中新增的字段格式为:"level":"debug"
#fields_under_root: false

# 可以指定Filebeat忽略指定时间段以外修改的日志内容,比如2h(两个小时)或者5m(5分钟)。
#ignore_older: 0

# 如果一个文件在某个时间段内没有发生过更新,则关闭监控的文件handle。默认1h
#close_older: 1h

# Defines the buffer size every harvester uses when fetching the file
# 每个harvester监控文件时,使用的buffer的大小
#harvester_buffer_size: 16384

# 日志文件中增加一行算一个日志事件,max_bytes限制在一次日志事件中最多上传的字节数,多出的字节会被丢弃
#max_bytes: 10485760

### 多行选项
# Mutiline 可用于跨越多行的日志消息。这对于 Java 堆栈跟踪或 C 行继续很常见

# 必须匹配的 regexp 模式。示例模式匹配所有开始 [
#multiline.pattern: ^\[

# 定义在模式下设置的模式是否应该被否定。默认值为 false.
#multiline.negate: false

# 匹配可以设置为 "后" 或 "之前"。它用于定义是否应将行追加到模式 (不匹配) 之前或之后, 或者只要模式不匹配 (基于否定.
# Note:后是等同于前和前是等价于下 Logstash
#multiline.match: after


#=============================Filebeat 模块 ===============================

filebeat.config.modules:
# 配置加载全局配置的模式(一个目录)
path: ${path.config}/modules.d/*.yml

# 设置为true来启用配置重载
reload.enabled: false

# 检查路径下的文件更改的期间(多久检查一次)
#reload.period: 10s

#==================== Elasticsearch 模板设置 ==========================

setup.template.settings:
index.number_of_shards: 3
#index.codec: best_compression
#_source.enabled: false

#============================== Kibana =====================================

# 从版本6.0.0 开始, 仪表板通过 Kibana API 加载。
# 这需要 Kibana 端点配置.
setup.kibana:

# Kibana Host
# 方案和端口可以被排除, 并将被设置为默认 (http and 5601)
# 如果您指定和附加路径, 则该方案是必需的: http://localhost:5601/path
# IPv6 地址应始终定义为: https://[2001:db8::1]:5601
#host: "localhost:5601"

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# 要连接到的主机的数组。
hosts: ["localhost:9200"]

# 可选协议和基本身份验证凭据。
#protocol: "https"
#username: "elastic"
#password: "changeme"

#----------------------------- Logstash output --------------------------------
#output.logstash:
# The Logstash hosts
#hosts: ["localhost:5044"]

# 可选的 SSL。默认为 off。
# 用于 HTTPS 服务器验证的根证书列表
#ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

# SSL 客户端身份验证证书
#ssl.certificate: "/etc/pki/client/cert.pem"

# 客户端证书密钥
#ssl.key: "/etc/pki/client/cert.key"

#----------------------------- Kafka output -------------------------------- #output.kafka:
    #enabled: true
    #hosts: []
#topic: 'topic'
#================================ Logging =====================================

# 设置日志级别。默认日志级别为 "信息"。
# 用的日志级别有: critical, error, warning, info, debug
#用的日志级别有: 关键、错误、警告、信息、调试
#logging.level: debug

# 在调试级别, 您可以有选择地仅对某些组件启用日志记录。
#要启用所有选择器, 请使用 ["*"]。其他选择器的例子是 "beat",
# "publish", "service".
#logging.selectors: ["*"]
 
© 著作权归作者所有

刘小恺(Kyle) wechat
如有疑问可联系博主