以下是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。