Cherry-pick #15422 to 7.x: Introduce CLI flag -environment #15829
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #15422 to 7.x branch. Original message:
Type of change
What does this PR do?
Introduce CLI flags -environment to control the default logging settings
the Beat should use if no logging is configured. The behavior of -e does
not change. By replacing
-e
with-environment system
in the systemunit file we continue to log to stdout/stderr by default, but users are
still able to overwrite settings.
For now (I'm targeting 7.x) I tried to not introduce any breaking changes one way or the other on the config file or CLI level. So the idea is to replace the
-e
flag with the-environment
flag in the systemd unit file. If-environment systemd
is given the default log output is stdout/stderr, while we keep file based logging as default for other environments.Why is it important?
If beats are started via systemd unit files the
-e
CLI flag is added to the list of CLI arguments. This was introduced in #8942. The-e
flag its purpose is to disable the configured logging output and always log to stdout/stderr. By to enforcing the-e
flag the users logging configurations is not honored (for example see the reports in #12024).Checklist
How to test this PR locally
The PR changes how beats are started as Windows Service, macOS service (installed via launchctl), docker container, and via systemd (deb/rpm). For testing Beats must be installed in a few different environment types to check if logs are correctly written to the default target and if log settings can be overwritten.
Running beat locally via command line:
-environment systemd
is given on the command line-environment
flag, without logging configured should create log files as usualRunning a beat via systemd:
/var/log/<beatname>
when settinglogging.to_stderr: false
andlogging.to_file: true
Running beat using old init scripts:
/var/log/<beatname>
by defaultRunning as container:
docker log
is this is really the case.Running on windows
Running as service on macOS
Related issues