在Debian上配置Filebeat主要涉及编辑/etc/filebeat/filebeat.yml
文件。以下是一个基本的配置文件示例及其详解:
filebeat.inputs:
- type: log
paths:
- /var/log/*.log
exclude_files: ['*.gz']
fields:
app_id: my_app
fields_under_root: true
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{+YYYY.MM.dd}"
document_type: my_custom_type
filebeat.inputs
type
: 指定输入类型,这里使用的是log
,表示从日志文件中读取数据。paths
: 指定要监控的日志文件路径,可以使用通配符。exclude_files
: 排除某些文件类型,例如这里的.gz
文件。fields
: 向输出的每条日志添加额外的信息,例如app_id
。fields_under_root
: 设置为true
时,新增的fields
会成为顶级目录,而不是放在fields
目录下。output.elasticsearch
hosts
: 指定Elasticsearch的地址和端口。index
: 指定Elasticsearch中的索引名称,可以使用动态模板。document_type
: 指定输出到Elasticsearch时的文档类型。global.config_dir
harvester.buffer_size
harvester.max_bytes
max_bytes
限制在一次日志事件中最多上传的字节数,多出的字节会被丢弃。multiline.pattern
multiline.negate
pattern
条件取反。multiline.match
multiline.max_lines
multiline.timeout
multiline.tail_files
true
时,Filebeat从文件尾开始监控文件新增内容。close_renamed
close_removed
ignore_older
close_older
force_close_files
close_older
之前一直保持文件的handle。scan_frequency
document_type
以上就是Debian上Filebeat配置文件的基本详解,根据实际需求,您可能还需要进行更多的配置。