# Kubernetes filebeat best practices

**URL:** https://discuss.elastic.co/t/kubernetes-filebeat-best-practices/305270
**Category:** Beats
**Tags:** filebeat
**Created:** [May 20, 2022, 9:51am UTC](https://discuss.elastic.co/t/kubernetes-filebeat-best-practices/305270 "2022-05-20T09:51:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lbchv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lbchv/32/105972_2.png) [@lbchv](https://discuss.elastic.co/u/lbchv)
#### Post date: [May 20, 2022, 9:51am UTC](https://discuss.elastic.co/t/kubernetes-filebeat-best-practices/305270/1 "2022-05-20T09:51:15Z")

</div>

The documentation says to avoid harvesting symlinks when dialing with file rotation ([link](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#rotating-logs)):

> When dealing with file rotation, avoid harvesting symlinks. Instead use the paths setting to point to the original file, and specify a pattern that matches the file you want to harvest and all of its rotated files.

But at the same time in the section about kubernetes autodiscover symlink example given in path ([link](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html#_kubernetes)):

```auto
filebeat.autodiscover:
  providers:
    - type: kubernetes
      templates:
        - condition:
            equals:
              kubernetes.namespace: kube-system
          config:
            - type: container
              paths:
                - /var/log/containers/*-${data.kubernetes.container.id}.log
              exclude_lines: ["^\\s+[\\-`('.|_]"] # drop asciiart lines

```

Symlinks in /var/log/containers\*.log points to log files in /var/log/pods which are rotated by kubelet.

What is best practices? Is there documentation mistake?

---

<div class="post-metadata">

### Author: ![khoa102](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@khoa102](https://discuss.elastic.co/u/khoa102)
#### Post date: [May 31, 2022, 2:31am UTC](https://discuss.elastic.co/t/kubernetes-filebeat-best-practices/305270/2 "2022-05-31T02:31:55Z")

</div>

Hi, I am also interested in this topic. Did you find something about this? I use this setting for my Kubernetes cluster and it worked well before. But recently, there seems to be a problem with either log rotation or heavy load. I would like to know the best practices for setting up Filebeat on Kubernetes to see if this is related to the problem I encounter.

---

<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: [June 28, 2022, 4:32am UTC](https://discuss.elastic.co/t/kubernetes-filebeat-best-practices/305270/3 "2022-06-28T04:32:18Z")

</div>

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