Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logging): Implement structured logging #15751

Merged
merged 9 commits into from
Sep 6, 2024
Prev Previous commit
Next Next commit
Document new option
  • Loading branch information
srebhan committed Sep 2, 2024
commit 013f044a552967f3694fe6200a8518d3b36c4dc7
14 changes: 7 additions & 7 deletions cmd/telegraf/agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
## Log only error level messages.
# quiet = false

## Log target controls the destination for logs and can be one of "file",
## "stderr" or, on Windows, "eventlog". When set to "file", the output file
## is determined by the "logfile" setting.
## Log target controls the destination for logs and can be one of "text",
## "structured" or, on Windows, "eventlog". The output file (if any) is
srebhan marked this conversation as resolved.
Show resolved Hide resolved
## determined by the "logfile" setting.
# logtarget = "file"
srebhan marked this conversation as resolved.
Show resolved Hide resolved

## Name of the file to be logged to when using the "file" logtarget. If set to
## the empty string then logs are written to stderr.
## Name of the file to be logged to or stderr if unset or empty. This
## setting is ignored for the "eventlog" target.
# logfile = ""

## The logfile will be rotated after the time interval specified. When set
Expand All @@ -80,9 +80,9 @@
# log_with_timezone = ""

## Override default hostname, if empty use os.Hostname()
hostname = ""
# hostname = ""
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false
# omit_hostname = false

## Method of translating SNMP objects. Can be "netsnmp" (deprecated) which
## translates by calling external programs snmptranslate and snmptable,
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func NewConfig() *Config {
Interval: Duration(10 * time.Second),
RoundInterval: true,
FlushInterval: Duration(10 * time.Second),
LogTarget: "file",
LogTarget: "text",
LogfileRotationMaxArchives: 5,
},

Expand Down
8 changes: 4 additions & 4 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ The agent table configures Telegraf and the defaults used across all plugins.
Log only error level messages.

- **logtarget**:
Log target controls the destination for logs and can be one of "file",
"stderr" or, on Windows, "eventlog". When set to "file", the output file is
Log target controls the destination for logs and can be one of "text",
"structured" or, on Windows, "eventlog". The output file (if any) is
determined by the "logfile" setting.

- **logfile**:
Name of the file to be logged to when using the "file" logtarget. If set to
the empty string then logs are written to stderr.
Name of the file to be logged to or stderr if unset or empty. This
setting is ignored for the "eventlog" target.

- **logfile_rotation_interval**:
The logfile will be rotated after the time interval specified. When set to
Expand Down