-
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
[8.15](backport #4932) Update event logger configuration via Fleet and environment variable (container command) #5109
Conversation
Cherry-pick of 72c1ebd has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
…(container command) (#4932) This commit adds the ability to receive event logger output configuration via Fleet. Previously only the log level was received via Fleet and persisted. Fleet can store the event logger configuration in the overrides section from the policy, allowing users to change and persist this configuration. The Elastic-Agent needs this configuration at startup, so whenever the Elastic-Agent receives a new policy from Fleet, it compares the event logging output configuration with its current one, if it is different, it is persisted to disk and the Elastic-Agent re-execs. When it re-starts it reads the new values from the persistent store and applies them. --------- Co-authored-by: Pierre HILBERT <[email protected]> (cherry picked from commit 72c1ebd)
a7a6ed4
to
0e8afe7
Compare
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
|
I've been trying but I cannot manage to reproduce this failure... I'll re-run the job to see what happens. |
This pull request has not been merged yet. Could you please review and merge it @belimawr? 🙏 |
This reverts commit d5aea61.
Quality Gate failedFailed conditions |
What does this PR do?
If Fleet sends an event logging output configuration different than the one that's running, save it to the encrypted store and re-exec the Elastic-Agent to use the new configuration.
This PR adds the ability to receive event logger configuration via Fleet. Previously only the log level was received via Fleet and persisted.
Fleet can store the logging configuration in the policy via the
overrides
option, whenever the Elastic-Agent receives the policy (including at startup), it correctly parses this configuration. This PR enable those values to be used to configure the event logger.When a policy is received the policy handler compares
agent.logging.event_data.to_stderr
andagent.logging.event_data.to_files
with it's current values, if the policy contains different values, they're persisted in the disk store, and the Elastic-Agent re-execs. When it re-starts it reads the new values from the persistent store and applies them.Note fore reviewers
This PR is built on top of #4909, hence I'm keeping it in draft until #4909 is merged and I can rebase ontomain
.Because this PR enables changing the log output (from disk to stderr or vice versa) I believe it's better to just re-start the Elastic-Agent instead of trying to do it at runtime. This will help to keep the logs consistent and avoid any possible race condition or the necessity to lock the logger while stopping/starting new outputs.
Why is it important?
Once #4549 gets merged the event logger won't be configurable via Fleet, this PR enables their configuration via Fleet.
Checklist
./changelog/fragments
using the changelog toolDisruptive User Impact
How to test this PR locally
Test the container command
mock-es
and run it to return StatusNotAcceptable on all requests:mock-es -nonindex 100
FLEET_ENROLL=1
FLEET_URL=https://fleet-server.elastic.co:443
FLEET_ENROLLMENT_TOKEN=c2VjcmV0LXRva2Vu
EVENTS_TO_STDERR=true
./elastic-agent container
Fleet-Managed Elastic-Agent
mock-es
and run it to return StatusNotAcceptable on all requests:mock-es -nonindex 100
journalctl -lfu elastic-agent.service
and ensure you see logs like this:Related issues
Questions to ask yourself
Closes #4874
This is an automatic backport of pull request #4932 done by Mergify.