-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log by default to journald on systems with systemd (#8942)
Add `-e` flag to command line when running beats from systemd so beats logs are collected by journald by default in systems with systemd. Add also some environment variables so command line flags can be more easily overriden with a drop-in unit or with `systemctl edit`. Add documentation about the use of Beats with systemd.
- Loading branch information
Showing
10 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
[[running-with-systemd]] | ||
=== {beatname_uc} and systemd | ||
|
||
The DEB and RPM packages include a service unit for Linux systems with | ||
systemd. On these systems, you can manage {beatname_uc} by using the usual | ||
systemd commands. | ||
|
||
==== Start and stop {beatname_uc} | ||
|
||
Use `systemctl` to start or stop {beatname_uc}: | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl start {beatname_lc} | ||
------------------------------------------------ | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl stop {beatname_lc} | ||
------------------------------------------------ | ||
|
||
By default, the {beatname_uc} service starts automatically when the system | ||
boots. To enable or disable auto start use: | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl enable {beatname_lc} | ||
------------------------------------------------ | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl disable {beatname_lc} | ||
------------------------------------------------ | ||
|
||
|
||
==== {beatname_uc} status and logs | ||
|
||
To get the service status, use `systemctl`: | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl status {beatname_lc} | ||
------------------------------------------------ | ||
|
||
Logs are stored by default in journald. To view the Logs, use `journalctl`: | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
journalctl -u {beatname_lc}.service | ||
------------------------------------------------ | ||
|
||
NOTE: The unit file included in the packages sets the `-e` flag by default. | ||
This flag makes {beatname_uc} log to stderr and disables other log outputs. | ||
Systemd stores all output sent to stderr in journald. | ||
|
||
[float] | ||
=== Customize systemd unit for {beatname_uc} | ||
|
||
The systemd service unit file includes environment variables that you can | ||
override to change the default options. | ||
|
||
[cols="<h,<,<m",options="header",] | ||
|======================================= | ||
| Variable | Description | Default value | ||
| BEAT_LOG_OPTS | Log options | `-e` | ||
| BEAT_CONFIG_OPTS | Flags for configuration file path | +-c /etc/{beatname_lc}/{beatname_lc}.yml+ | ||
| BEAT_PATH_OPTS | Other paths | +-path.home /usr/share/{beatname_lc} -path.config /etc/{beatname_lc} -path.data /var/lib/{beatname_lc} -path.logs /var/log/{beatname_lc}+ | ||
|======================================= | ||
|
||
To override these variables, create a drop-in unit file in the | ||
+/etc/systemd/system/{beatname_lc}.service.d+ directory. | ||
|
||
For example a file with the following content placed in | ||
+/etc/systemd/system/{beatname_lc}.service.d/debug.conf+ | ||
would override `BEAT_LOG_OPTS` to enable debug for Elasticsearch output. | ||
|
||
["source", "systemd", subs="attributes"] | ||
------------------------------------------------ | ||
[Service] | ||
Environment=BEAT_LOG_OPTS="-e -d elasticsearch" | ||
------------------------------------------------ | ||
|
||
To use settings from the {beatname_uc} file, empty the environment | ||
variable. For example: | ||
|
||
["source", "systemd", subs="attributes"] | ||
------------------------------------------------ | ||
[Service] | ||
Environment=BEAT_LOG_OPTS="" | ||
------------------------------------------------ | ||
|
||
To apply your changes, reload the systemd configuration and restart | ||
the service: | ||
|
||
["source", "sh", subs="attributes"] | ||
------------------------------------------------ | ||
systemctl daemon-reload | ||
systemctl restart {beatname_lc} | ||
------------------------------------------------ | ||
|
||
NOTE: It is recommended that you use a configuration management tool to | ||
include drop-in unit files. If you need to add a drop-in manually, use | ||
+systemctl edit {beatname_lc}.service+. |
This file contains 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
This file contains 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