-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Elastic Agent] Send Agent logs to elasticsearch #19811
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
d53e7d2
to
ae55a79
Compare
❕ Build Aborted
Expand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
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 maybe another look for logger part from @urso would be handy
} | ||
|
||
encoder := zapcore.NewJSONEncoder(ecszap.ECSCompatibleEncoderConfig(logp.JSONEncoderConfig())) | ||
return ecszap.WrapCore(zapcore.NewCore(encoder, rotator, logp.DebugLevel.ZapLevel())), nil |
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.
I wonder if we could have reduced some of the plumbing by exporting logp.createLogOutput only
and split configure into configure log output
and configure logging with output
. The zapcore.Core
is basically the output here. The core that is produced here coulbe be build via CreateLogOutput(agentConfig)
.
Allowing us to pass a separate output (zapcore.Core
) to logp.Configure
might allow us in the future to change how logging will be configured in other products, but still work with existing code in Beats that requires logp to function as is (e.g. for agent or collector).
Splitting can also be interesting for testing, as we could allow tests to configure a Core that logs to the active *testing.T
. This might be helpful when investigating test failures.
@urso I am trying to make as little change as possible, don't want to cause a big refactor on FF day. I have added a |
@urso Added comment. |
* Work on logging twice. * Work on agent logging to fleet. * Commit example index strategy. * More work on logging to ES. * Revert change to release/version.go * Fix indexes for metricbeat sidecars. * Add to changelog. * Fix fmt. * Don't expose zapLevel, add ConfigureWithOutputs. * Update comment. * Update comment. (cherry picked from commit 2297636)
* Work on logging twice. * Work on agent logging to fleet. * Commit example index strategy. * More work on logging to ES. * Revert change to release/version.go * Fix indexes for metricbeat sidecars. * Add to changelog. * Fix fmt. * Don't expose zapLevel, add ConfigureWithOutputs. * Update comment. * Update comment. (cherry picked from commit 2297636)
* Work on logging twice. * Work on agent logging to fleet. * Commit example index strategy. * More work on logging to ES. * Revert change to release/version.go * Fix indexes for metricbeat sidecars. * Add to changelog. * Fix fmt. * Don't expose zapLevel, add ConfigureWithOutputs. * Update comment. * Update comment.
What does this PR do?
Agent will now always log to
${path.data}/logs/elastic-agent-json.log
no matter the settings fromelastic-agent.yml
(those still apply, for the user specified choice). With monitoring always on Filebeat will always be started and will send the logs from${path.data}/logs/elastic-agent-json.log
to elasticsearch.The spawned filebeat and metricbeat now log to
filebeat-json.log
andmetricbeat-json.log
in JSON format and forward to elasticsearch.Indexes:
logs-elastic.agent-default
{logs,metrics}-elastic.agent.filebeat-default
{logs,metrics}-elastic.agent.metricbeat-default
Why is it important?
So all logs of the Elastic Agents on hosts are in elasticsearch so monitoring/troubleshooting of the Fleet is much easier.
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
.Related issues