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

Add logrotation section on Running Filebeat on k8s #24120

Merged
merged 2 commits into from
Feb 19, 2021

Conversation

ChrsMark
Copy link
Member

What does this PR do?

This PR adds logrotation section on docs about Running Filebeat on Kubernetes. This is part of action items to cover logrotation issues occurring to users running Filebeat on Kubernetes.

Why is it important?

Users that are not aware of logrotation on their k8s clusters might face issue with lost or duplicate events.

@jsoriano @kvch let me know what you think.

Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark added docs v7.11.0 v7.12.0 kubernetes Enable builds in the CI for kubernetes labels Feb 19, 2021
@ChrsMark ChrsMark self-assigned this Feb 19, 2021
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 19, 2021
@ChrsMark ChrsMark added the Team:Platforms Label for the Integrations - Platforms team label Feb 19, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Platforms)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Feb 19, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 19, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #24120 updated

  • Start Time: 2021-02-19T11:15:56.876+0000

  • Duration: 21 min 25 sec

  • Commit: 2c8440e

Trends 🧪

Image of Build Times

❕ Flaky test report

No test was executed to be analysed.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add to the reference config the wildcard recommended in the linked docs?
From:

- type: container
paths:
- /var/log/containers/*.log

To:

    - type: container
      paths:
        - /var/log/containers/*.log*

_Kubernetes is not responsible for rotating logs, but rather a deployment tool should set up a solution to address that_.
Different logrotation strategies can cause issues that might make Filebeat losing events or even duplicating events.
Users can find more information about Filebeat's logrotation best practises at Filebeat's
https://www.elastic.co/guide/en/beats/filebeat/current/file-log-rotation.html#file-log-rotation[logrotation specific documentation].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let the docs builder build the url to the proper version and document, use a placeholder like this one:

Suggested change
https://www.elastic.co/guide/en/beats/filebeat/current/file-log-rotation.html#file-log-rotation[logrotation specific documentation].
<<file-log-rotation,log rotation specific documentation>>.

Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark
Copy link
Member Author

ChrsMark commented Feb 19, 2021

Should we add to the reference config the wildcard recommended in the linked docs?
From:

- type: container
paths:
- /var/log/containers/*.log

To:

    - type: container
      paths:
        - /var/log/containers/*.log*

I don't think it will work. /var/log/containers/ contains symlinks to /var/log/pods/.../....log and then to /var/lib/docker/container/abcd/abcd.log (in case of docker) so a log file inside /var/log/containers/ will only point to the current "active" log file through the symlink. In case of docker, rotated files are under /var/lib/docker/containers/:

ll -la /var/lib/docker/containers/**
...
...
/var/lib/docker/containers/fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e:
total 46816
drwx------  4 root root     4096 Feb 10 02:17 .
drwx------ 50 root root    12288 Feb 10 13:20 ..
drwx------  2 root root     4096 Feb  5 11:25 checkpoints
-rw-------  1 root root    12448 Feb  5 11:25 config.v2.json
-rw-r-----  1 root root  7862893 Feb 10 13:20 fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e-json.log
-rw-r-----  1 root root 10000134 Feb 10 02:17 fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e-json.log.1
-rw-r-----  1 root root 10000076 Feb  9 12:16 fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e-json.log.2
-rw-r-----  1 root root 10000029 Feb  8 22:18 fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e-json.log.3
-rw-r-----  1 root root 10000117 Feb  8 08:33 fbc13e9d289fcc15fbc2c60154ec16623e9db6a22f3c53c3f1d83c2c5f63a12e-json.log.4
-rw-r--r--  1 root root     2233 Feb  5 11:25 hostconfig.json
drwx------  2 root root     4096 Feb  5 11:25 mounts

Switching the manifest to /var/lib/docker/containers/*/*.log* is not a good idea since it will not cover runtimes other than docker 😞 , so better to leave it as is?

@jsoriano
Copy link
Member

Switching the manifest to `/var/lib/docker/containers//.log* is not a good idea since it will not cover runtimes other than docker disappointed , so better to leave it as is?

Ok, lets leave it as is, we may need to review this in any case soon after the removal of docker from kubernetes and possible upcoming changes in logs managemeent in K8s.

@ChrsMark ChrsMark merged commit ea5d413 into elastic:master Feb 19, 2021
@jsoriano jsoriano added the needs_backport PR is waiting to be backported to other branches. label Feb 19, 2021
@ChrsMark ChrsMark added v7.13.0 and removed needs_backport PR is waiting to be backported to other branches. labels Feb 19, 2021
ChrsMark added a commit to ChrsMark/beats that referenced this pull request Feb 19, 2021
ChrsMark added a commit to ChrsMark/beats that referenced this pull request Feb 19, 2021
ChrsMark added a commit to ChrsMark/beats that referenced this pull request Feb 19, 2021
ChrsMark added a commit that referenced this pull request Feb 19, 2021
ChrsMark added a commit that referenced this pull request Feb 19, 2021
ChrsMark added a commit that referenced this pull request Feb 19, 2021
v1v added a commit to v1v/beats that referenced this pull request Feb 22, 2021
* upstream/master:
  [Elastic Agent] Fix docker entrypoint for elastic-agent. (elastic#24155)
  [PACKAGING] Push docker images with the architecture in the version (elastic#24121)
  [Agent] Add agent standalone manifests for system module & Pod's log collection (elastic#23938)
  indicator type url is in upper case (elastic#24152)
  [Filebeat] Document netflow internal_networks and set default (elastic#24110)
  [Filebeat] Adding fixes to the TI module (elastic#24133)
  [Enhancement] Add RotateOnStartup feature flag for file output (elastic#19347)
  [Ingest Manager] Fix: Successfully installed and enrolled agent running standalone (elastic#24128)
  Set Elastic licence type for APM server Beats update job (elastic#24122)
  Add logrotation section on Running Filebeat on k8s (elastic#24120)
  [CI] Run if manual UI (elastic#24116)
  [CI] enable x-pack/heartbeat in the CI (elastic#23873)
v1v added a commit to v1v/beats that referenced this pull request Feb 23, 2021
…dows-7

* upstream/master:
  Remove OSS reference for kibana and elasticsearch (elastic#24164)
  Skip flaky TestActions on MacOSx (elastic#23966)
  [Filebeat][AWS] Fix vpcflow pipeline exception: Cannot invoke "Object.getClass()" because "receiver" is null (elastic#24167)
  [Elastic Agent] Fix docker entrypoint for elastic-agent. (elastic#24155)
  [PACKAGING] Push docker images with the architecture in the version (elastic#24121)
  [Agent] Add agent standalone manifests for system module & Pod's log collection (elastic#23938)
  indicator type url is in upper case (elastic#24152)
  [Filebeat] Document netflow internal_networks and set default (elastic#24110)
  [Filebeat] Adding fixes to the TI module (elastic#24133)
  [Enhancement] Add RotateOnStartup feature flag for file output (elastic#19347)
  [Ingest Manager] Fix: Successfully installed and enrolled agent running standalone (elastic#24128)
  Set Elastic licence type for APM server Beats update job (elastic#24122)
  Add logrotation section on Running Filebeat on k8s (elastic#24120)
  [CI] Run if manual UI (elastic#24116)
  [CI] enable x-pack/heartbeat in the CI (elastic#23873)
  chore: comment out the E2E (elastic#24109)
  chore: add-backport-next (elastic#24098)
  Adjust the position of the architecture name in Dockerlogbeat tarball (elastic#24095)
  Update dependencies for M1 support in System (elastic#24019)
v1v added a commit to v1v/beats that referenced this pull request Feb 23, 2021
…-arm

* upstream/master: (24 commits)
  Add example input autodsicover config (elastic#24157)
  Empty configuration options generate `<no value>` string for azure-eventhub input (elastic#24156)
  Remove OSS reference for kibana and elasticsearch (elastic#24164)
  Skip flaky TestActions on MacOSx (elastic#23966)
  [Filebeat][AWS] Fix vpcflow pipeline exception: Cannot invoke "Object.getClass()" because "receiver" is null (elastic#24167)
  [Elastic Agent] Fix docker entrypoint for elastic-agent. (elastic#24155)
  [PACKAGING] Push docker images with the architecture in the version (elastic#24121)
  [Agent] Add agent standalone manifests for system module & Pod's log collection (elastic#23938)
  indicator type url is in upper case (elastic#24152)
  [Filebeat] Document netflow internal_networks and set default (elastic#24110)
  [Filebeat] Adding fixes to the TI module (elastic#24133)
  [Enhancement] Add RotateOnStartup feature flag for file output (elastic#19347)
  [Ingest Manager] Fix: Successfully installed and enrolled agent running standalone (elastic#24128)
  Set Elastic licence type for APM server Beats update job (elastic#24122)
  Add logrotation section on Running Filebeat on k8s (elastic#24120)
  [CI] Run if manual UI (elastic#24116)
  [CI] enable x-pack/heartbeat in the CI (elastic#23873)
  chore: comment out the E2E (elastic#24109)
  chore: add-backport-next (elastic#24098)
  Adjust the position of the architecture name in Dockerlogbeat tarball (elastic#24095)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs kubernetes Enable builds in the CI for kubernetes Team:Platforms Label for the Integrations - Platforms team v7.11.0 v7.11.2 v7.12.0 v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants