Skip to content

feat(logging): Add syslog as log format - #20087

Open
hsdfat wants to merge 2 commits into
influxdata:masterfrom
hsdfat:feat/logging-syslog
Open

hsdfat wants to merge 2 commits into
influxdata:masterfrom
hsdfat:feat/logging-syslog

Conversation

@hsdfat

@hsdfat hsdfat commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds logformat = "syslog" so the agent can log to the local syslog daemon, as asked in the issue.

logtarget is deprecated, so this follows the Windows eventlog logger and registers syslog as a log format in logger/. It uses the standard library's log/syslog, so there is no new dependency and no new config key. Messages are sent with the daemon facility and the instance name (telegraf) as tag. Severities map as error → err, warn → warning, info → info, debug/trace → debug. logfile, rotation and log_with_timezone don'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, where eventlog already 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 log redirect. The agent sample config and docs/CONFIGURATION.md are updated.

Checklist

Related issues

resolves #16732

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
@telegraf-tiger telegraf-tiger Bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Nov 6, 2026
Comment thread logger/syslog_logger.go Outdated
// 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 (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@skartikey skartikey self-assigned this Nov 12, 2026
@telegraf-tiger

Copy link
Copy Markdown
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

⚠️ This pull request increases the Telegraf binary size by 7.30 % for linux amd64 (new size: 330.7 MB, nightly size 308.2 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syslog for agent logtarget

2 participants