filebeat优化参数
filebeat的配置文件filebeat.yml,其实有两个参数,
close_older: 1h
说明:Close older closes the file handler for which were not modified for longer then close_older. Time strings like 2h (2 hours), 5m (5 minutes) can be used.
即如果一个文件在某个时间段内没有发生过更新,则关闭监控的文件handle,默认1小时。
force_close_files: false
说明:This option closes a file, as soon as the file name changes. This config option is recommended on windows only. Filebeat keeps the files it's reading open. This can cause issues when the file is removed, as the file will not be fully removed until also Filebeat closes the reading. Filebeat closes the file handler after ignore_older. During this time no new file with the same name can be created. Turning this feature on the other hand can lead to loss of data on rotate files. It can happen that after file rotation the beginning of the new file is skipped, as the reading starts at the end. We recommend to leave this option on false but lower the ignore_older value to release files faster.
即当文件名称有变化时,包括改名和删除,会自动关闭一个文件。
这两个参数结合起来,根据应用需求,一个文件30分钟内不更新,则需要关闭句柄,文件改名或删除,需要关闭句柄,close_older: 30m
force_close_files: true
可以满足,filebeat采集日志,以及定时删除历史文件,这两个任务的基本要求。
filebeat部署链接
从零进阶--教你如何使用Filebeat实现日志可视化收集