From wikistone
(Created page with "Advanced logging to remote syslog server... Using Pi-Hole as an example source. Documenting here because the reddit and internet searches suck. GPT is hot garbage too, due to...") |
|||
| Line 1: | Line 1: | ||
Advanced logging to remote syslog server... Using Pi-Hole as an example source. Documenting here because the reddit and internet searches suck. GPT is hot garbage too, due to old examples being so prevalent. | Advanced logging to remote syslog server... Using Pi-Hole as an example source. Documenting here because the reddit and internet searches suck. GPT is hot garbage too, due to old examples being so prevalent. | ||
| + | |||
| + | |||
==Intermediate Log Forwarding== | ==Intermediate Log Forwarding== | ||
| Line 27: | Line 29: | ||
reopenOnTruncate="on") | reopenOnTruncate="on") | ||
</pre> | </pre> | ||
| + | |||
| + | |||
==Advanced Log Forwarding== | ==Advanced Log Forwarding== | ||
| Line 48: | Line 52: | ||
reopenOnTruncate="on") | reopenOnTruncate="on") | ||
</pre> | </pre> | ||
| + | |||
| + | |||
==Parameters== | ==Parameters== | ||
| Line 64: | Line 70: | ||
| reopenOnTruncate || Re-opens file after it is closed and rotated. | | reopenOnTruncate || Re-opens file after it is closed and rotated. | ||
|} | |} | ||
| − | |||
| − | |||
| Line 85: | Line 89: | ||
pihole:x:997:www-data,syslog | pihole:x:997:www-data,syslog | ||
</pre> | </pre> | ||
| − | |||
Revision as of 16:29, 20 October 2024
Advanced logging to remote syslog server... Using Pi-Hole as an example source. Documenting here because the reddit and internet searches suck. GPT is hot garbage too, due to old examples being so prevalent.
Contents
Intermediate Log Forwarding
Forward all text logs from Pi-Hole to remote syslog server.
/etc/rsyslog.d/90-pihole.conf
# Pi-Hole logs to remote server
local1.* action(type="omfwd" target="10.0.0.10" port="514" protocol="udp"
action.resumeRetryCount="100"
queue.type="linkedList" queue.size="10000")
# Define log sources:
module(load="imfile" PollingInterval="30")
input(type="imfile" File="/var/log/pihole/pihole.log"
Tag="pihole"
PersistStateInterval="100"
Severity="notice"
Facility="local1"
reopenOnTruncate="on")
input(type="imfile" File="/var/log/pihole/pihole-FTL.log"
Tag="piFTL"
PersistStateInterval="100"
Severity="info"
Facility="local1"
reopenOnTruncate="on")
Advanced Log Forwarding
Alternatively, just queries from the Pi-Hole log.
/etc/rsyslog.d/90-pihole.conf
# Pi-Hole query logs to remote server
if $syslogfacility-text == 'local1' and $msg contains 'query' then {
action(type="omfwd" target="10.0.0.10" port="514" protocol="udp" action.resumeRetryCount="100" queue.type="linkedList" queue.size="10000")
stop
}
module(load="imfile" PollingInterval="30")
input(type="imfile" File="/var/log/pihole/pihole.log"
Tag="pihole"
PersistStateInterval="100"
Severity="notice"
Facility="local1"
reopenOnTruncate="on")
Parameters
| Parameter | Description |
|---|---|
| Tag | The program tag. |
| PersistStateInterval=[n] | Replaces state file, requires number of lines between updates. Default 0 is close of file. (crappy) Lower number means more processing. Higher means fewer updates. |
| Severity | Severity level :: {emerg,alert,crit,err,warning,notice,info,debug} :: {0..7} |
| Facility | syslog facility :: {local[0..15]} :: {0..15} |
| reopenOnTruncate | Re-opens file after it is closed and rotated. |
Read Permissions
Ensure rsyslog can read the file. For example, with pi-hole logs, the syslog user needs to be a member of the pihole group.
Error
me@pihole:~$ sudo systemctl status rsyslog ... Feb 32 00:11:22 pihole rsyslogd[33324]: imfile: error accessing file '/var/log/pihole/pihole.log': Permission denied [v8.2001.0]
Fix
/etc/group ... pihole:x:997:www-data,syslog
References
https://rsyslog.readthedocs.io/en/latest/configuration/filters.html
https://rsyslog.readthedocs.io/en/latest/configuration/modules/imfile.html
https://www.rsyslog.com/doc/configuration/modules/imfile.html#persiststateinterval
.