在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配置文件的基本詳解,根據實際需求,您可能還需要進行更多的配置。