如何减少Logstash的RAM使用量?

tkqqtvp1  于 2023-08-01  发布在  Logstash
关注(0)|答案(2)|浏览(219)

我正在寻找我的Logstash RAM问题的答案,因为它几乎是100%。我做了很多搜索,但他们没有为我工作。下面的代码是我的logstash.conf文件。我觉得它需要一些小的触摸。
Logstash.conf:

input {
  file {
        path => ["c:/mylogs/*.txt"]
        start_position => "beginning" 
        discover_interval => 10
        stat_interval => 10
        sincedb_write_interval => 10
        close_older => 10
        codec => "json"
  }
}

filter {
  date {
        match => ["mydate","yyyy-MM-dd HH:mm:ss.SSSS" ]
        timezone => "UTC"  
  }
  date {
        match => ["TimeStamp", "ISO8601"]
  }

  json {
        source => "request"
        target => "parsedJson"
  }
}

output {
  stdout {
        codec => rubydebug
  }
  elasticsearch {
        hosts => [ "http://localhost:9200" ]
        index => "log-%{+YYYY.MM}"
  }
}

字符串

utugiqy6

utugiqy61#

Logstash使用JVM运行。logstash使用的JVM选项可以在logstash文件夹(see the doc)的config文件夹jvm.options文件中配置。在文件中,您可以设置一个-Xmx选项来设置最大堆大小,这将限制使用的最大内存。
通过优化logstash page,您还可以配置批处理大小和worker数量,以减少正在进行的事件数量,这应该会减少RAM的使用,但也会减少logstash的吞吐量。

hi3rlvi2

hi3rlvi22#

设置Logstash JVM选项

imply setting LS_JAVA_OPTS will not work because that only appends to the default Logstash JVM Options and does not replace them. You can set JAVA_OPTS but that will not work unless you also est HEAP_DUMP_PATH. Below is the final configuration we use.

# replace logstash Java options since we only have 4 cores in production
# you will get a waring in the logs
# LS_JAVA_OPTS only appends
export JAVA_OPTS="-XX:+UseSerialGC -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError"
# logstash will append Xmx
export LS_HEAP_SIZE="1g"
# this needs to be set because logstash will always append it
# if it's missing you will get an empty VM argument and it won't start
export HEAP_DUMP_PATH="-XX:HeapDumpPath=$LOGSTASH/heapdump.hprof"

字符串

相关问题