以下是Debian上Filebeat的日志管理技巧:
配置日志輸出
filebeat.yml設置logging.level(如debug/info/warn/error)控制日志詳細程度。logging.to_files并指定路徑(如/var/log/filebeat/),設置keepfiles保留天數。日志輪轉與壓縮
logrotate工具(推薦):在/etc/logrotate.d/filebeat中配置輪轉策略,如每日輪轉、保留7天、壓縮舊日志。filebeat.yml中配置rotation.period和rotation.keep_files,但靈活性低于logrotate)。集中化日志分析
output.elasticsearch配置將日志發送至Elasticsearch,用Kibana可視化。output.prometheus輸出指標,通過Grafana創建監控儀表盤。實時監控與故障排查
journalctl -u filebeat -f實時查看服務日志。filebeat-input-mysql)針對性采集特定日志。性能優化
filebeat.yml中的queue.mem.events和max_bytes控制內存使用,避免OOM。