# Filebeat memory issues

**URL:** https://discuss.elastic.co/t/filebeat-memory-issues/197297
**Category:** Beats
**Tags:** filebeat
**Created:** [August 29, 2019, 9:09am UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297 "2019-08-29T09:09:19Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)
#### Post date: [August 29, 2019, 9:09am UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/1 "2019-08-29T09:09:19Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4ddc44a1981b6c0d342f0929e891eb918c1b63c5.png)  
Here's a (not very) pretty picture - the filebeats in our K8s cluster appear to start up, then over not-very-long increase their memory consumption until they crash with out of memory, then restart.

This is version 6.6.2, with a memory limit of 500M.

I am about to try fiddling with queue.mem.events ... but is there any general guidance about memory usage tuning for filebeat?

---

<div class="post-metadata">

### Author: ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)
#### Post date: [August 29, 2019, 10:06am UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/2 "2019-08-29T10:06:56Z")

</div>

Well, setting queue.mem.events to 1024 doesn't seem to have been helpful:

(1) It seems to be struggling to fetch the backlog of data, and keep up with continuing log generation

(2) Filebeat pods are still running out of memory and crashing and restarting.

---

<div class="post-metadata">

### Author: ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)
#### Post date: [August 29, 2019, 3:36pm UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/3 "2019-08-29T15:36:53Z")

</div>

I've now found [https://github.com/elastic/beats/issues/9302#issuecomment-490000600](https://github.com/elastic/beats/issues/9302#issuecomment-490000600) which didn't exist last time I went through this loop (or, at least, the fix in 6.8.1 didn't exist). Trying it to see what happens ...

---

<div class="post-metadata">

### Author: ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)
#### Post date: [August 29, 2019, 8:03pm UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/4 "2019-08-29T20:03:06Z")

</div>

Hi @TimWard,

Yes, please, try with 6.8.1 if possible, we backported some fixes for memory leaks related to autodiscover to this version.

---

<div class="post-metadata">

### Author: ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)
#### Post date: [August 30, 2019, 8:01am UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/5 "2019-08-30T08:01:06Z")

</div>

The removal of `add_kubernetes_metadata` made an enormous difference. The move to 6.8.1 may also have helped, but I did both together so am not sure. It's been running fine overnight, for the first time since we've tried running `filebeat` on Kubernetes.

Now, where did the `add_kubernetes_metadata` which caused the trouble come from? - I'm not absolutely certain but I think it was in the `filebeat-k8s.yaml` file which I downloaded from somewhere vaguely semi-official looking as "this is how you do `filebeat` on Kubernetes".

Here is the "after" memory usage on the same scale: ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/8/48154ebb8c5eca307a011f2ca5bdcfe258b1e771.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 27, 2019, 8:01am UTC](https://discuss.elastic.co/t/filebeat-memory-issues/197297/6 "2019-09-27T08:01:09Z")

</div>

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