在Debian系統上提升Filebeat的穩定性可以通過以下幾個步驟進行優化:
sudo apt update
sudo apt install filebeat
/etc/filebeat/filebeat.yml。filebeat.inputs 部分添加要監控的文件路徑。filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
ignore_older: 72h
output.elasticsearch:
hosts: ["localhost:9200"]
sudo systemctl start filebeat
sudo systemctl enable filebeat
multiline.pattern、multiline.negate、multiline.match 和 multiline.max_lines 等參數。json.keys_under_root 為 true,json.overwrite_keys 為 true,json.message_key 為 log,json.add_error_key 為 true。queue.type 設置為 persisted,并配置 queue.max_bytes 和 flush.min_events 等參數。ignore_older 參數忽略長時間未修改的日志文件。close_inactive 參數設置不活躍文件關閉時間。harvester_limit 參數限制每個input并行啟動的harvester數量。bulk_max_size 參數,啟用批量輸出。通過上述優化措施,可以顯著提升Filebeat在Debian上的穩定性和性能。建議在生產環境中根據實際場景選擇合適的配置參數,并建立完善的監控體系和問題排查流程,定期進行性能優化。