-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysutils/loki: add promtail rc.d script
Promtail is a log reader and it can be run as a service to gather the logs to be sent to remote loki server. For nodes that need to send logs only, promtail service and configuration file is needed PR: 274194, 274473 Signed-off-by: Christopher Beppler <freebsd@funzi.org> Approved by: Chirstopher Beppler <freebsd@funzi.org> (maintainer)
- Loading branch information
1 parent
ccbf8b7
commit b16c0ca
Showing
5 changed files
with
96 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- clients/cmd/promtail/promtail-local-config.yaml.orig 2023-10-05 01:40:22.549761000 +0000 | ||
+++ clients/cmd/promtail/promtail-local-config.yaml 2023-10-05 01:41:28.869261000 +0000 | ||
@@ -3,7 +3,7 @@ | ||
grpc_listen_port: 0 | ||
|
||
positions: | ||
- filename: /tmp/positions.yaml | ||
+ filename: /var/db/promtail/positions.yaml | ||
|
||
clients: | ||
- url: http://localhost:3100/loki/api/v1/push |
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,70 @@ | ||
#!/bin/sh | ||
|
||
# PROVIDE: promtail | ||
# REQUIRE: LOGIN | ||
# KEYWORD: shutdown | ||
|
||
# Add the following lines to /etc/rc.conf to enable promtail | ||
# promtail_enable="YES" | ||
# | ||
# promtail_enable (bool): | ||
# Set it to YES to enable promtail | ||
# Set to NO by default | ||
# promtail_user (string): | ||
# Set user that promtail will run under | ||
# Default is "%%PROMTAIL_USER%%" | ||
# promtail_group (string): | ||
# Set group that own promtail files | ||
# Default is "%%LOKI_GROUP%%" | ||
# promtail_config (string) | ||
# Set full path to config file | ||
# Default is "%%PREFIX%%/etc/promtail.yaml" | ||
# promtail_logfile (string) | ||
# Set full path to log file | ||
# Default is "/var/log/promtail/promtail.log" | ||
# promtail_loglevel (string) | ||
# Set log level. Only log messages with the given severity or above. | ||
# Valid levels: [debug, info, warn, error] | ||
# Default is "warn" | ||
# promtail_args (string) | ||
# Set additional command line arguments | ||
# Default is "" | ||
|
||
. /etc/rc.subr | ||
|
||
name=promtail | ||
rcvar=promtail_enable | ||
|
||
load_rc_config $name | ||
|
||
: ${promtail_enable:="NO"} | ||
: ${promtail_user:="%%PROMTAIL_USER%%"} | ||
: ${promtail_group:="%%LOKI_GROUP%%"} | ||
: ${promtail_config:="%%PREFIX%%/etc/promtail.yaml"} | ||
: ${promtail_logfile:="/var/log/promtail/promtail.log"} | ||
: ${promtail_loglevel:="warn"} | ||
|
||
pidfile="/var/run/${name}/${name}.pid" | ||
required_files="${promtail_config}" | ||
|
||
procname="%%PREFIX%%/bin/promtail" | ||
command="/usr/sbin/daemon" | ||
command_args="-p ${pidfile} -t ${name} -o ${promtail_logfile} \ | ||
${procname} \ | ||
--config.file=${promtail_config} \ | ||
--log.level=${promtail_loglevel} \ | ||
${promtail_args}" | ||
|
||
start_precmd="promtail_start_precmd" | ||
|
||
promtail_start_precmd() { | ||
if [ ! -d "/var/run/${name}" ]; then | ||
install -d -m 0750 -o ${promtail_user} -g ${promtail_group} "/var/run/${name}" | ||
fi | ||
|
||
if [ ! -d "/var/log/promtail" ]; then | ||
install -d -m 0750 -o ${promtail_user} -g ${promtail_group} "/var/log/promtail" | ||
fi | ||
} | ||
|
||
run_rc_command "$1" |
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