Syslog¶
The syslog
log method can be used to send logs to a local socket or remote syslog servers using UDP or TCP.
Configuration Keys¶
The following configuration keys apply to only the syslog target. The logging page lists general configuration which is shared with the file
logger.
Key | Type | Default |
---|---|---|
structured |
Bool | True |
destination |
String | /dev/log |
port |
Integer | 514 |
protocol |
String | udp |
Structured¶
Structured logging can be enabled/disabled with the structured
option. By default, logs sent to syslog servers are structured while file logs are not structured. An example of structured logs:
"date"="2024-01-21" "time"="14:05:05.949" "level"="INFO" "pid"="280406" "check_name"="TCP test to Google port 80" "file"="/code/exacheck/worker.py" "line"="201" "function"="success" "event"="info" "subsystem"="worker" "message"="Health check successful but service has not risen yet"
If disabled, the logs will look like this:
2024-01-21 14:21:27.731 | INFO | 284611 | TCP test to Google port 80 | /code/exacheck/worker.py:201 | success | info | worker | Health check successful but service has not risen yet
Destination¶
The destination to send logs to. May be a path to a socket, an IP address or hostname.
Port¶
If sending logs to a remote host, the port to send them to.
Protocol¶
The protocol to send the syslog messages with when logging to a remote host. Valid options are tcp
or udp
.
Info
UDP logging is preferred to ensure there are no delays should the syslog destination not be reachable.
Examples¶
These are some examples of what can be configured for the syslog
target.
Local Socket¶
Some examples of configuring logging to sockets:
A minimal configuration for a single log target:
A configuration for logging to multiple sockets with filtering:
Remote Syslog Servers¶
These examples are for logging to remote syslog servers.
A minimal UDP configuration looks like this:
The port may be changed and structured logs disabled:
TCP logging is configured the same way; the protocol just needs to be changed:
Multiple targets may be defined as usual:
---
logging:
# Send logs to 192.0.2.1 UDP port 5144
- method: syslog
destination: 192.0.2.1
port: 5144
protocol: udp
structured: false
# Send logs for announce/withdraw events using TCP to 192.0.2.100 port 514
- method: syslog
destination: 192.0.2.100
protocol: tcp
events:
- announce
- withdraw
# The list of health checks
checks:
- ...