Filebeat high memory usage v6.4.2

I am running a test using filebeat and 5 json log files each writing about 200 entries/second into its own json log file. I have not changed the defaults in filebeat other than the json entries:
json.message_key: level
json.keys_under_root: true
json.overwrite_keys: true

Filebeat is using 45 GB of virtual RAM according to top and is causing swap and high wait times across the system. What can we expect filebeat to handle and can we tweak the configuration to decrease ram usage?

Hi, can you share your full filebeat.yml configuration file? (Use the </> tool so it's properly formatted).

Most of the file, I apologize in advance for all the commented out sections:

###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat inputs =============================

filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /var/log/logtest/*.log
  close_inactive: 48h
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  json.message_key: level
  json.keys_under_root: true
  json.overwrite_keys: true

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  include_lines: ['action']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Multiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  #multiline.pattern: ^\[

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  #multiline.negate: false

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  #multiline.match: after


#============================= Filebeat modules ===============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  #host: "localhost:5601"

#============================= Elastic Cloud ==================================

# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
cloud.id: "xxxx"

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
cloud.auth: "elastic:xxxx"

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.


#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  #hosts: ["localhost:9200"]
  index: "logs-%{+yyyy.MM.dd}"

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"


setup.template.enabled: true
setup.template.overwrite: true
setup.template.name: "logs"
setup.template.pattern: "logs-*"
setup.dashboards.index: "logs-*" 
setup.template.overwrite: true

A monitoring entry from the filebeat log:

{"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":56590,"time":{"ms":76}},"total":{"ticks":109730,"time":{"ms":180},"value":109730},"user":{"ticks":53140,"time":{"ms":104}}},"info":{"ephemeral_id":"4b0993b1-0a6a-49d3-91d0-f2a9b16de0ab","uptime":{"ms":228565}},"memstats":{"gc_next":30138594736,"memory_alloc":15216983784,"memory_total":89118489664,"rss":12935168}},"filebeat":{"events":{"active":181,"added":281,"done":100},"harvester":{"open_files":5,"running":5}},"libbeat":{"config":{"module":{"running":0}},"output":{"events":{"active":26,"batches":1,"total":26}},"pipeline":{"clients":1,"events":{"active":340,"published":320,"total":319},"queue":{"acked":170}}},"registrar":{"states":{"current":5,"update":887},"writes":{"success":1,"total":1}},"system":{"load":{"1":8.72,"15":7.03,"5":9.06,"norm":{"1":0.2725,"15":0.2197,"5":0.2831}}}}}}

Hi @grantk

For debugging purposes, it might be useful to know the general structure of the JSON files you are using. I mean, 200 entries/json but how big they are, how many keys they could have or if they are multiline or single line.

A couple of things you can try tweaking are the internal queue, specially the min events value and the harvester buffer size

Single line - every log entry looks like this:

{"fields":{"environment":"dev","host":"utilszayo","ip":"xxxxxxxxxx","name":"logtest","version":"0.1","workerNum":0},"level":"action","@timestamp":"2018-11-02T18:19:53.024101851Z","message":"just a log from a worker not doing anything but logging - AND some random text to make our average byte length appromimate production etc etc etc let's log!"}

I plan to adjust a few of those settings and see how much things improve.

It's possible this problem was caused by an attempt to rotate all logs at once. The logrotate event ended up creating copies of the log files that did not match the input regex in filebeat.yml.

I have deleted the registry file and the log files, and filebeat seems to be behaving now. I will update with any new information next week.

Hope that helps.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.