Cherry-pick #15422 to 7.x: Introduce CLI flag -environment#15829
Merged
urso merged 2 commits intoelastic:7.xfrom Jan 24, 2020
Merged
Cherry-pick #15422 to 7.x: Introduce CLI flag -environment#15829urso merged 2 commits intoelastic:7.xfrom
urso merged 2 commits intoelastic:7.xfrom
Conversation
* Introduce CLI flag -environment 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 system unit file we continue to log to stdout/stderr by default, but users are still able to overwrite settings. * Add more environment types Add windows_service, macos_service, and container envionment types. If beats are installed using our scripts the `-environment` flag will always be set. Replace `-e` with `-environment docker` CLI flag in the Dockerfile. Although it's uncommon, users can not overwrite the logging configuration in docker containers as well. The docker(container) environment and systemd environment will default to stdout/stderr logging. All other environments continue to use file rotation as default. (cherry picked from commit 1d3d4d1)
jsoriano
approved these changes
Jan 24, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
-ewith-environment systemin 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
-eflag with the-environmentflag in the systemd unit file. If-environment systemdis 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
-eCLI flag is added to the list of CLI arguments. This was introduced in #8942. The-eflag its purpose is to disable the configured logging output and always log to stdout/stderr. By to enforcing the-eflag 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 systemdis given on the command line-environmentflag, without logging configured should create log files as usualRunning a beat via systemd:
/var/log/<beatname>when settinglogging.to_stderr: falseandlogging.to_file: trueRunning beat using old init scripts:
/var/log/<beatname>by defaultRunning as container:
docker logis this is really the case.Running on windows
Running as service on macOS
Related issues