Update logfile documentation

This commit is contained in:
Daniel Nelson 2019-05-03 10:55:11 -07:00
parent bcf7516a23
commit 74c9d7ace2
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
2 changed files with 55 additions and 43 deletions

View File

@ -136,19 +136,25 @@ The agent table configures Telegraf and the defaults used across all plugins.
service input to set the timestamp at the appropriate precision. service input to set the timestamp at the appropriate precision.
- **debug**: - **debug**:
Run telegraf with debug log messages. Log at debug level.
- **quiet**: - **quiet**:
Run telegraf in quiet mode (error log messages only). Log only error level messages.
- **logfile**: - **logfile**:
Specify the log file name. The empty string means to log to stderr. Log file name, the empty string means to log to stderr.
- **logfile_rotation_interval**: - **logfile_rotation_interval**:
Log file rotation time [interval][], e.g. "1d" means logs will rotated every day. Default is 0 => no rotation based on time. The logfile will be rotated after the time interval specified. When set to
0 no time based rotation is performed.
- **logfile_rotation_max_size**: - **logfile_rotation_max_size**:
The log file max [size][]. Log files will be rotated when they exceed this size. Default is 0 => no rotation based on file size. The logfile will be rotated when it becomes larger than the specified size.
When set to 0 no size based rotation is performed.
- **logfile_rotation_max_archives**: - **logfile_rotation_max_archives**:
Maximum number of archives (rotated) files to keep. Older log files are deleted first. Maximum number of rotated archives to keep, any older logs are deleted. If
This setting is only applicable if `logfile_rotation_interval` and/or `logfile_rotation_max_size` settings have been specified (otherwise there is no rotation) set to -1, no archives are removed.
Default is 0 => all rotated files are deleted. Use -1 to keep all archives.
- **hostname**: - **hostname**:
Override default hostname, if empty use os.Hostname() Override default hostname, if empty use os.Hostname()

View File

@ -72,9 +72,10 @@ func NewConfig() *Config {
c := &Config{ c := &Config{
// Agent defaults: // Agent defaults:
Agent: &AgentConfig{ Agent: &AgentConfig{
Interval: internal.Duration{Duration: 10 * time.Second}, Interval: internal.Duration{Duration: 10 * time.Second},
RoundInterval: true, RoundInterval: true,
FlushInterval: internal.Duration{Duration: 10 * time.Second}, FlushInterval: internal.Duration{Duration: 10 * time.Second},
LogfileRotationMaxArchives: 5,
}, },
Tags: make(map[string]string), Tags: make(map[string]string),
@ -140,22 +141,26 @@ type AgentConfig struct {
UTC bool `toml:"utc"` UTC bool `toml:"utc"`
// Debug is the option for running in debug mode // Debug is the option for running in debug mode
Debug bool Debug bool `toml:"debug"`
// Logfile specifies the file to send logs to
Logfile string
// The log file rotation interval
LogfileRotationInterval internal.Duration
// The log file max size. Logs will rotated when they exceed this size.
LogfileRotationMaxSize internal.Size
// The max number of log archives to keep
LogfileRotationMaxArchives int
// Quiet is the option for running in quiet mode // Quiet is the option for running in quiet mode
Quiet bool Quiet bool `toml:"quiet"`
// Log file name, the empty string means to log to stderr.
Logfile string `toml:"logfile"`
// The logfile will be rotated when it becomes larger than the specified
// size. When set to 0 no size based rotation is performed.
LogfileRotationInterval internal.Duration `toml:"logfile_rotation_interval"`
// Maximum number of rotated archives to keep, any older logs are deleted.
// If set to -1, no archives are removed.
LogfileRotationMaxSize internal.Size `toml:"logfile_rotation_max_size"`
// Maximum number of rotated archives to keep, any older logs are deleted.
// If set to -1, no archives are removed.
LogfileRotationMaxArchives int `toml:"logfile_rotation_max_archives"`
Hostname string Hostname string
OmitHostname bool OmitHostname bool
} }
@ -275,24 +280,25 @@ var agentConfig = `
## Valid time units are "ns", "us" (or "µs"), "ms", "s". ## Valid time units are "ns", "us" (or "µs"), "ms", "s".
precision = "" precision = ""
## Logging configuration: ## Log at debug level.
## Run telegraf with debug log messages. # debug = false
debug = false ## Log only error level messages.
## Run telegraf in quiet mode (error log messages only). # quiet = false
quiet = false
## Specify the log file name. The empty string means to log to stderr. ## Log file name, the empty string means to log to stderr.
logfile = "" # logfile = ""
## Rotation settings, only applicable when log file name is specified.
## Log file rotation time interval, e.g. "1d" means logs will rotated every day. Default is 0 => no rotation based on time. ## The logfile will be rotated after the time interval specified. When set
# logfile_rotation_interval = "1d" ## to 0 no time based rotation is performed.
## The log file max size. Log files will be rotated when they exceed this size. Default is 0 => no rotation based on file size. # logfile_rotation_interval = "0d"
# logfile_rotation_max_size = "10 MB"
## Maximum number of archives (rotated) files to keep. Older log files are deleted first. ## The logfile will be rotated when it becomes larger than the specified
## This setting is only applicable if logfile_rotation_interval and/or logfile_rotation_max_size settings have been specified (otherwise there is no rotation) ## size. When set to 0 no size based rotation is performed.
## Default is 0 => all rotated files are deleted. # logfile_rotation_max_size = "0MB"
## Use -1 to keep all archives.
## Analogous to logrotate "rotate" setting http://man7.org/linux/man-pages/man8/logrotate.8.html ## Maximum number of rotated archives to keep, any older logs are deleted.
# logfile_rotation_max_archives = 0 ## If set to -1, no archives are removed.
# logfile_rotation_max_archives = 5
## Override default hostname, if empty use os.Hostname() ## Override default hostname, if empty use os.Hostname()
hostname = "" hostname = ""