我正在使用在独立系统(无云或集群)中运行的 Logstash-5.6.5(在 Windows 中)。计划查看一些日志文件并将其发布到本地运行 elasticsearch。但是当检查 Logstash 的内存使用情况时,没有配置来查看任何文件,它显示大约 600MB 内存使用情况。当我进一步添加输入文件管道配置时,它会进一步添加内存(为了观看 3 个日志文件,它添加了多达 70MB,但我计划添加更多多达 20 个日志)。
1. 这是预期的行为吗?
2. 有什么办法可以减少logstash占用的大量内存?
最佳答案
经过几天的研究,下面是我对我的问题的回答。
以下是我们可以优化 Logstash 内存的方法:
set "LS_JAVA_OPTS=-Xms512m –Xmx512m"
否则可能这可以添加在 setup.bat 文件的开头。
通过这种方式,我将 Logstash 的总内存使用量限制为最大 620 MB。
通过这种方式,我断言我的 Logstash 过滤器配置是否经过优化。
在我的情况下,我只需要观看最近的文件而忽略旧文件,我已相应地设置了如下配置:
input {
file {
#The application log path that will match with the rolling logs.
path => "c:/path/to/log/app-1.0-*.log"
#I didn't want logs older than an hour.
#If that older file gets updated with a new entry
#that will become the new file and the new entry will be read by Logstash
ignore_older => 3600
#I wanted to have only the very recent files to be watched.
#Since I am aware there won't be more then 5 files I set it to 5.
max_open_files => 5
#If the log file is not updated for 5 minutes close it.
#If any new entry gets added then it will be opened again.
close_older => 300
}
}
关于performance - 如何减少 Logstash 内存使用量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48576637/