Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filebeat OOMs on very long lines #19500

Closed
benbuzbee opened this issue Jun 29, 2020 · 4 comments
Closed

Filebeat OOMs on very long lines #19500

benbuzbee opened this issue Jun 29, 2020 · 4 comments
Assignees
Labels
Team:Services (Deprecated) Label for the former Integrations-Services team

Comments

@benbuzbee
Copy link

  • Version: 7.8.0
  • Operating System: Ubuntu 18.04 LTS

Repro

  1. Create this filebeat.yml in a new directory
filebeat.inputs:
  - type: log
    paths:
    - /test/readme.log
    max_bytes: 1024
output.console:
  pretty: true

Note: The config specifies a 1MB limit on a single file

Run this bash command:

dd if=/dev/zero of=$(pwd)/readme.log bs=1MB count=100 && docker run -d --memory=50MB --memory-swappiness=0 -v $(pwd):$(pwd) -v $(pwd)/readme.log:/test/readme.log docker.elastic.co/beats/filebeat:7.8.0 filebeat --path.config $(pwd) -e

Note: This command creates a 100MB file called "readme.log" and mounts it to filebeat as the /test/readme.log file. It sets a 50MB limit in the docker container.

Expected: command runs file, filebeat reads 1MB of data from readme.log before realizing the line is too long, and then seeks without buffering the rest of the line in memory.

Actual: filebeat reads all 100MB of the file into memory searching for a newline and OOMs

$ docker inspect 0945c | grep "OOM"
            "OOMKilled": true,

This is pretty bad for us, if we make a mistake and log a huge line filebeat gets OOM killed. Filebeat should stop buffering a line once it exceeds max_bytes

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 29, 2020
@andresrc andresrc added the Team:Services (Deprecated) Label for the former Integrations-Services team label Jun 30, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 30, 2020
@aleksmaus
Copy link
Member

aleksmaus commented Jul 1, 2020

Opened a PR that should fix this problem. In the test case, I believe, there is a typo where the author mentioned
"Note: The config specifies a 1MB limit on a single file" while max_bytes: 1024 is in bytes.
Please correct me if I'm wrong.

@benbuzbee
Copy link
Author

Yes it is a typo. Thanks for your change! It looks like a good candidate since it would prevent filebeat from being OOM killed, however I think it could be improved by just skipping the big line instead of returning from the reader

@aleksmaus
Copy link
Member

Sure, can update the PR to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

No branches or pull requests

5 participants