在CentOS系統中,Filebeat的配置文件通常位于/etc/filebeat/filebeat.yml
。要設置Filebeat配置文件,請按照以下步驟操作:
打開終端。
使用文本編輯器打開Filebeat配置文件。例如,使用nano編輯器,輸入以下命令:
sudo nano /etc/filebeat/filebeat.yml
filebeat.inputs
: 定義要監視的文件或目錄。例如,要監視/var/log/*.log
文件,可以這樣設置:filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
filebeat.processors
: 定義處理器,例如解壓縮、刪除字段等。例如,要刪除名為tags
的字段,可以這樣設置:processors:
- remove_fields:
fields: ["tags"]
output.elasticsearch
: 定義Elasticsearch輸出設置。例如,要連接到本地的Elasticsearch實例,可以這樣設置:output.elasticsearch:
hosts: ["localhost:9200"]
setup.template.settings
: 定義Elasticsearch索引模板設置。例如,要設置索引的刷新間隔為30秒,可以這樣設置:setup.template.settings:
index.refresh_interval: 30s
完成修改后,保存并關閉配置文件。
重啟Filebeat服務以應用更改:
sudo systemctl restart filebeat
現在,Filebeat將根據您的配置文件設置運行。如果需要進一步自定義Filebeat,請查閱官方文檔:https://www.elastic.co/guide/en/beats/filebeat/current/configuration-file.html