Created
February 6, 2018 16:10
-
-
Save tuxfight3r/52162ed1abc1b043cb2fe35c821570f6 to your computer and use it in GitHub Desktop.
custom splunk journald logrotate
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
# Rotate client logs | |
# log file already has this context set. | |
# -rw-r-----. root root system_u:object_r:var_log_t:s0 /var/log/journald_splunk.log | |
# -rw-r-----. root root system_u:object_r:var_log_t:s0 /var/log/journald_splunk.log-2018020315 | |
/var/log/journald_splunk.log { | |
hourly | |
maxsize 3M | |
rotate 3 | |
missingok | |
delaycompress | |
notifempty | |
sharedscripts | |
create 640 root root | |
prerotate | |
/bin/systemctl stop journald-splunk-log.service | |
endscript | |
postrotate | |
/bin/systemctl start journald-splunk-log.service | |
endscript | |
} |
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
[Unit] | |
Description=Journald to Splunk Log Converter | |
After=network.target | |
[Service] | |
Type=simple | |
Restart=always | |
ExecStartPre=/usr/bin/journalctl --vacuum-time=30days | |
ExecStart=/bin/sh -c '/usr/bin/journalctl --since "1 hour ago" -f -o json > /var/log/journald_splunk.log 2>&1' | |
RestartSec=600s | |
StandardOutput=syslog | |
StandardError=syslog | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment