Ubuntu 上 Filebeat 日志管理实用技巧
一 定位与查看 Filebeat 自身日志
二 调整 Filebeat 自身日志级别与输出
三 系统级日志轮转 logrotate 推荐做法
/var/log/filebeat/*.log {
daily
rotate 7
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/bin/filebeat -c /etc/filebeat/filebeat.yml -path.config /etc/filebeat test config >/dev/null 2>&1 && systemctl reload filebeat
endscript
}
四 使用 Filebeat 内置文件输出进行自轮转
output.file:
path: "/var/log/filebeat"
filename: "filebeat-%{+yyyy.MM.dd}.log"
max_size: 100MB
max_files: 5
五 被采集日志的归档与保留策略
PUT _ilm/policy/logstash-policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": { "max_size": "50gb", "max_age": "7d" }
}
},
"delete": {
"min_age": "30d",
"actions": { "delete": {} }
}
}
}
}