-
Notifications
You must be signed in to change notification settings - Fork 148
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
Collect process (beats) stdout and stderr #455
Conversation
🌐 Coverage report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
logMsg: "stdout log", | ||
logLevel: zapcore.InfoLevel, | ||
}, | ||
{name: "capture stderr", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe alight the name
with other properties in the structure initialization, here and above
if proc != nil && proc.Process != nil { | ||
_ = proc.Process.Kill() | ||
} | ||
_ = proc.Process.Kill() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, there is no way that the proc or the proc.Process can be nil here?
seeing that the nil check was here before and now is removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems indeed odd to me, I would keep that and separate investigation. See elastic/beats#26126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, I was removing some debug logs and removed more than I should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndersonQ Only a few things:
- Add a changelog entry.
- Revert the proc.kill
- I would fix the alignment.
Other than the above it looks good to me.
if proc != nil && proc.Process != nil { | ||
_ = proc.Process.Kill() | ||
} | ||
_ = proc.Process.Kill() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems indeed odd to me, I would keep that and separate investigation. See elastic/beats#26126
This reverts commit 6a166d3.
What does this PR do?
The Elastic Agent now collects the
strout
andstderr
of the (sub)process it runs.Why is it important?
When application crashes (panics), the "crash/panic" information is lost as they log directly to files and by default the stdout and stderr of a sub process is connected to
os.DevNull
.Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Panic a beat and check the logs are there :)
There is the
agent-88-collest-beats-stdout-stderr
beats branch has a modified filebeat that exposes a HTTP server which will panic and log to stdout and stderr upon request.Just compile the agent and the beats together, run the agent with any policy that will install and run a filebeat (filebeat_monitoring also works).
Look for logs like
starting HTTP panic server on port :424X
, where X is a random number chosen at startup. The agent should already log it, but filebeat will log it as well.Once you have it, you can:
Related issues
Logs