Log*_*han 8 performance memory-management logstash logstash-file logstash-configuration
我正在使用在独立系统(无云或群集)中运行的Logstash-5.6.5(在Windows中)。计划观看一些日志文件并将其发布到本地运行elasticsearch。但是,当检查Logstash的内存使用情况时,如果没有配置监视任何文件的配置,则显示大约600MB内存使用情况。当我进一步添加输入文件管道配置时,它进一步增加了内存(为观看3个日志文件,它总共增加了70MB,但我计划增加多达20个日志)。 
1.这是预期的行为吗? 
2.有什么方法可以通过logstash减少大量内存使用?
Log*_*han 13
经过几天的研究,下面是我对问题的回答。
以下是我们优化Logstash内存的方法:
Logstash内存使用量主要是通过堆大小来累积的。在启动Logstash(对于我的Windows版本)之前,通过在环境变量LS_JAVA_OPTS中设置堆内存大小,如下所示,可以有效地控制它:
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 
  }
}