Hello Team - I have been trying to redirect the agent and backend logs to the service specific files, however seeing some challenges. I did walk through the Sensu-agent not running - Solved , however still having some questions that I thought I will post here for clarity.
I am using systemd service for managing the agent as well as the backend.
[Unit]
Description=The Sensu Agent process.
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
LimitNOFILE=65535
ExecStart=/usr/share/sensugo/sensu-agent start
Restart=on-failure
RestartSec=1min
WorkingDirectory=/
[Install]
WantedBy=multi-user.target
And it looks like the startup is using chroot.
cat /usr/share/sensugo/sensu-agent
name=sensu-agent
program=/usr/sbin/sensu-agent
args=“start”
pidfile="/var/run/sensugo/$name.pid"
user=“sensu”
group=“sensu”
chroot="/"
chdir="/"
chroot --userspec “$user”:"$group" “$chroot” sh -c "
cd "chroot\"
ulimit -n {MAX_OPEN_FILES}
exec “$program” $args
" >> /var/log/sensu/sensu-agent.log 2>> /var/log/sensu/sensu-agent.log &
If I don’t use chroot and call the binary directly, the logs are not getting redirected to the service specific log files. Is it possible to direct the log files with a simple bash -c “sensu-agent binary start” >> log_file 2>>log_file while still able to write to the log files ?
I also followed this guide this https://docs.sensu.io/sensu-go/latest/guides/systemd-logs/ , but no luck.
Wish we had a parameter to pass the log file location to keep it simple , similar to sensu-core
Any other recommendations please ?