Filebeat 在 Debian 上的日志轮转可以通过配置 logrotate 工具来实现。以下是配置步骤:
sudo apt-get update
sudo apt-get install logrotate
/etc/logrotate.d/filebeat
:sudo nano /etc/logrotate.d/filebeat
/path/to/your/filebeat/logs/*.log {
daily
missingok
rotate 7
compress
notifempty
create 0640 root adm
sharedscripts
postrotate
if [ -f /var/run/filebeat/filebeat.pid ]; then
/usr/share/filebeat/filebeat -e -c /etc/filebeat/filebeat.yml -d "*"
fi
endscript
}
这里的配置表示:
保存并关闭配置文件。
测试 logrotate 配置是否正确:
sudo logrotate -f /etc/logrotate.d/filebeat
如果没有错误信息,说明配置正确。
现在,Filebeat 的日志轮转应该已经按照配置文件中的设置进行。如果需要调整轮转策略,只需修改 /etc/logrotate.d/filebeat
文件即可。