# Filebeat handler open rotated log files

**URL:** https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694
**Category:** Beats
**Tags:** filebeat
**Created:** [August 19, 2019, 7:55am UTC](https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694 "2019-08-19T07:55:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nomis](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@nomis](https://discuss.elastic.co/u/nomis)
#### Post date: [August 19, 2019, 7:55am UTC](https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694/1 "2019-08-19T07:55:25Z")

</div>

On our kuberntes cluster we rotate the logs using the dockerd option "--log-opt max-size and --log-opt max-file". When the log are rotated filebeat still hold the rotated log file. We keep only 3 rotated log files, this will result in fielbeat still referencing deleted files.

The issue is similar to [Filebeat Holds open rotated log files](https://discuss.elastic.co/t/filebeat-holds-open-rotated-log-files/138259). But i did not see any workaround or solution.

I see option "close\_rename" but not sure how safe is to enable this option. Or is there any other solution? Im using filebeat version 6.7 Please let me know.

---

<div class="post-metadata">

### Author: ![nomis](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@nomis](https://discuss.elastic.co/u/nomis)
#### Post date: [August 19, 2019, 1:25pm UTC](https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694/2 "2019-08-19T13:25:27Z")

</div>

To add to it, it looks like its not closing the file "docker\_id.log.1" even after the close\_inactive time of 5m

---

<div class="post-metadata">

### Author: ![kumarabhi](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kumarabhi](https://discuss.elastic.co/u/kumarabhi)
#### Post date: [August 19, 2019, 9:24pm UTC](https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694/3 "2019-08-19T21:24:02Z")

</div>

Filebeat configs are safe.

I am using the closing options (provided below) and do see file closing due to inactivity

File is inactive: /home/xyz/log//stderr.txt. Closing because close\_inactive of 5m0s reached.

Did you try close\_removed: true for stopping harvesters when old files are deleted ?

```
 ### Harvester closing options

  # Close inactive closes the file handler after the predefined period.
  # The period starts when the last line of the file was, not the file ModTime.
  # Time strings like 2h (2 hours), 5m (5 minutes) can be used.
  close_inactive: 5m

  # Close renamed closes a file handler when the file is renamed or rotated.
  # Note: Potential data loss. Make sure to read and understand the docs for this option.
  close_renamed: false

  # When enabling this option, a file handler is closed immediately in case a file can't be found
  # any more. In case the file shows up again later, harvesting will continue at the last known position
  # after scan_frequency.
  close_removed: true

  # Closes the file handler as soon as the harvesters reaches the end of the file.
  # By default this option is disabled.
  # Note: Potential data loss. Make sure to read and understand the docs for this option.
  close_eof: false
```

---

<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 16, 2019, 9:24pm UTC](https://discuss.elastic.co/t/filebeat-handler-open-rotated-log-files/195694/4 "2019-09-16T21:24:06Z")

</div>

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