# Filebeat with high memory consumption after logrotate

**URL:** https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497
**Category:** Beats
**Tags:** filebeat
**Created:** [August 3, 2020, 4:50am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497 "2020-08-03T04:50:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mohanisch](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mohanisch](https://discuss.elastic.co/u/mohanisch)
#### Post date: [August 3, 2020, 4:50am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/1 "2020-08-03T04:50:45Z")

</div>

Hello!

We use Filebeat (in Docker, version 7.8) to send logs to Logstash. Every night at 0:01 logrotate runs on the machine where Filebeat is running. It is rotating ~20-25 logfiles. Logrotate is configured with following options:

```auto
daily
missingok
rotate 7
compress
copytruncate
dateext
dateformat .%Y-%m-%d-%s.rotlog

```

From the moment logrotate starts, Filebeat starts allocating a lot of memory.

 ![Screenshot 2020-08-03 at 06.40.09](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e94385568027bca731f5fbff0345f0063fb3b1dc.png)  
Filebeat is reporting, that the file got truncated, sure, that is true.

We've already tried out:

- mem limit configured to container - this ends up in a restart loop of that container
- configured `queue.spool` instead of `queue.mem`
- configured `close_inactive` to 30min (in the night logs are used less)
- configured `client_inactivity_timeout` in Logstash (in the night logs are used less)
- split the log rotation into time frames (cron is starting different jobs between 0:01 and 0:10)

All these attempts have not helped to throttle the memory consumption of Filebeat. After the first rotation, the consumption is very high.

So what's the problem here?

Cheers  
Marco

---

<div class="post-metadata">

### Author: ![mohanisch](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mohanisch](https://discuss.elastic.co/u/mohanisch)
#### Post date: [August 4, 2020, 2:45am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/2 "2020-08-04T02:45:39Z")

</div>

This is an Scrrenshot from this night. What is happening there? Why is Filebeat collecting \> 5GB of RAM?

 ![Screenshot 2020-08-04 at 04.43.46](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bde4d35da584984421f360d1256da153f4c35522.png)

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 4, 2020, 3:08am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/3 "2020-08-04T03:08:32Z")

</div>

Welcome to our community! 😃  
Which part of the memory is that actually measuring?

---

<div class="post-metadata">

### Author: ![mohanisch](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mohanisch](https://discuss.elastic.co/u/mohanisch)
#### Post date: [August 4, 2020, 3:22am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/4 "2020-08-04T03:22:38Z")

</div>

Hey Mark,  
this is the container memory usage. I

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 4, 2020, 3:35am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/5 "2020-08-04T03:35:17Z")

</div>

I will take an educated guess and suggest that this is virtual memory being used by Filebeat juggling the files that it wants to read and has read.

Hopefully someone will pop in and ask a few more specific questions, as I can't really comment on how to reduce it.

---

<div class="post-metadata">

### Author: ![mohanisch](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mohanisch](https://discuss.elastic.co/u/mohanisch)
#### Post date: [August 4, 2020, 3:47am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/6 "2020-08-04T03:47:53Z")

</div>

I'm just a bit surprised that Filebeat needs up to 6GB of memory after the truncate. It is only a spike, but it would be good to get a grip on this behaviour. I would like to understand what happens internally and also understand why Filebeat uses \< 500MB during the day but after the rotation an undefined amount.

I'm currently a bit at a loss as to how we can get a handle on this. This setup is currently not in production, only on a test environment. On production, logs are available around the clock.

 ![Screenshot 2020-08-04 at 05.46.50](https://us1.discourse-cdn.com/elastic/original/3X/3/e/3e4ebe2d4ec27e79ebb8bcdd273f173ecd7d4c0f.png)

---

<div class="post-metadata">

### Author: ![mohanisch](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mohanisch](https://discuss.elastic.co/u/mohanisch)
#### Post date: [August 20, 2020, 7:56am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/7 "2020-08-20T07:56:12Z")

</div>

Anyone? No ideas?

---

<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 17, 2020, 9:56am UTC](https://discuss.elastic.co/t/filebeat-with-high-memory-consumption-after-logrotate/243497/8 "2020-09-17T09:56:15Z")

</div>

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