Repository navigation
Conversation
Add a "syslog" log format for non-Windows systems that sends Telegraf's own log messages to the local syslog daemon using the "daemon" facility and the instance name as tag. resolves influxdata#16732
| // Network and address of the syslog server. Empty values connect to the local | ||
| // syslog daemon. Those variables are only modified in unit tests to redirect | ||
| // the output. | ||
| var ( |
There was a problem hiding this comment.
[question] Could network and address live as unexported fields on Config instead of package vars that only tests write? The tests are in the same package so they can set them directly, which drops the global state and the cleanup reset. It also gives the remote-server option you mentioned a natural home later.
There was a problem hiding this comment.
Yes, that is cleaner. Done in 901c571: syslogNetwork and syslogAddress are unexported fields of Config now, the package variables and the test helper that reset them are gone, and the tests set the fields on their own config.
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Summary
Adds
logformat = "syslog"so the agent can log to the local syslog daemon, as asked in the issue.logtargetis deprecated, so this follows the Windowseventloglogger and registers syslog as a log format inlogger/. It uses the standard library'slog/syslog, so there is no new dependency and no new config key. Messages are sent with thedaemonfacility and the instance name (telegraf) as tag. Severities map as error →err, warn →warning, info →info, debug/trace →debug.logfile, rotation andlog_with_timezonedon't apply, because syslog adds its own timestamp. If no local syslog daemon is reachable, Telegraf fails at startup, the same as other logger setup errors. The format is not available on Windows, whereeventlogalready exists.Remote syslog servers are out of scope here. They could be added later with an address option if wanted.
Unit tests send through a UDP listener and check the tag, the message and the priority for each level, including messages that come through the stdlib
logredirect. The agent sample config anddocs/CONFIGURATION.mdare updated.Checklist
Related issues
resolves #16732