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

fix(logging): handle file rotation of splunkd_sterr.log #684

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

zarend
Copy link

@zarend zarend commented Aug 26, 2024

Fix issue with logging of standard error messages where standard error logs would be lost when logging large amount of data to stadard error.

Splunk logs to splunkd_stdout.log as the Unix standard error device. This file is rotated. According to What Splunk software logs about itself, "The historical rotation for most internal logs is 5 files of 25MB each".

docker-splunk container tails the output of splunkd_stdout.log to standard output. The existing behavior is that the container receives Splunk's standard error messages until splunkd_stdout.log is about 25MB. When the log files passes 25MB, Splunk rotates the log file by rename splunkd_stdout.log to something like splunkd_stoudt1.log and creating a new splunkd_stdout.log.

By default, tail follows the file descriptor of argument file. I believe that if the file is renamed, it continutes to track the file descriptor of argument file, if that is available. This is not the behavior we want for file rotation, since we always want to follow the information that goes to splunkd_stdout.log and not splunkd_stdout1.log, splunkd_stdout2.log, etc.

Fix standard error logs not surfacing by passing -F option to unix tail command. This causes tail to keep retrying to open argument file name if it becomes unavailable.

Change in behavior to print standard error logs to standard out for entire lifetime of the program, instead of stopping after the first file rotation.

Fix #626

Fix issue with logging of standard error messages where standard error
logs would be lost when logging large amount of data to stadard error.

Splunk logs to splunkd_stdout.log as the Unix standard error device.
This file is rotated. According to [What Splunk software logs about itself](https://docs.splunk.com/Documentation/Splunk/9.2.1/Troubleshooting/WhatSplunklogsaboutitself), "The historical rotation for most internal logs is 5 files of 25MB each".

docker-splunk container tails the output of splunkd_stdout.log to
standard output. The existing behavior is that the container receives
Splunk's standard error messages until splunkd_stdout.log is about 25MB.
When the log files passes 25MB, Splunk rotates the log file by rename
splunkd_stdout.log to something like splunkd_stoudt1.log and creating a
new splunkd_stdout.log.

By default, tail follows the file descriptor of argument file. I believe
that if the file is renamed, it continutes to track the file descriptor
of argument file, if that is available. This is not the behavior we want
for file rotation, since we always want to follow the information that
goes to splunkd_stdout.log and not splunkd_stdout1.log,
splunkd_stdout2.log, etc.

Fix standard error logs not surfacing by passing `-F` option to unix
tail command. This causes tail to keep retrying to open argument file
name if it becomes unavailable.

Change in behavior to print standard error logs to standard out for
entire lifetime of the program, instead of stopping after the first file
rotation.

Fix splunk#626
@zarend zarend requested a review from a team as a code owner August 26, 2024 20:54
Copy link
Contributor

@michaellee-splunk michaellee-splunk left a comment

Choose a reason for hiding this comment

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

Have built images with the proposed changes internal and verified no impact to existing behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tailing to stdout does not follow rotated/renamed files
3 participants