fix(agent): Fix buffer directory config and document (#15661)

This commit is contained in:
Dane Strandboge 2024-07-30 03:18:10 -05:00 committed by GitHub
parent fe7321e35b
commit 790c21e7cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 6 deletions

View File

@ -1513,8 +1513,10 @@ func (c *Config) buildOutput(name string, tbl *ast.Table) (*models.OutputConfig,
return nil, err
}
oc := &models.OutputConfig{
Name: name,
Filter: filter,
Name: name,
Filter: filter,
BufferStrategy: c.Agent.BufferStrategy,
BufferDirectory: c.Agent.BufferDirectory,
}
// TODO: support FieldPass/FieldDrop on outputs
@ -1529,8 +1531,6 @@ func (c *Config) buildOutput(name string, tbl *ast.Table) (*models.OutputConfig,
c.getFieldString(tbl, "name_suffix", &oc.NameSuffix)
c.getFieldString(tbl, "name_prefix", &oc.NamePrefix)
c.getFieldString(tbl, "startup_error_behavior", &oc.StartupErrorBehavior)
c.getFieldString(tbl, "buffer_strategy", &oc.BufferStrategy)
c.getFieldString(tbl, "buffer_directory", &oc.BufferDirectory)
if c.hasErrs() {
return nil, c.firstErr()
@ -1549,6 +1549,7 @@ func (c *Config) missingTomlField(_ reflect.Type, key string) error {
switch key {
// General options to ignore
case "alias", "always_include_local_tags",
"buffer_strategy", "buffer_directory",
"collection_jitter", "collection_offset",
"data_format", "delay", "drop", "drop_original",
"fielddrop", "fieldexclude", "fieldinclude", "fieldpass", "flush_interval", "flush_jitter",

View File

@ -356,7 +356,12 @@ The agent table configures Telegraf and the defaults used across all plugins.
The type of buffer to use for telegraf output plugins. Supported modes are
`memory`, the default and original buffer type, and `disk`, an experimental
disk-backed buffer which will serialize all metrics to disk as needed to
improve data durability and reduce the chance for data loss.
improve data durability and reduce the chance for data loss. This is only
supported at the agent level.
- **buffer_directory**:
The directory to use when in `disk` buffer mode. Each output plugin will make
another subdirectory in this directory with the output plugin's name.
## Plugins

View File

@ -347,7 +347,11 @@ func (r *RunningOutput) writeMetrics(metrics []telegraf.Metric) error {
func (r *RunningOutput) LogBufferStatus() {
nBuffer := r.buffer.Len()
r.log.Debugf("Buffer fullness: %d / %d metrics", nBuffer, r.MetricBufferLimit)
if r.Config.BufferStrategy == "disk" {
r.log.Debugf("Buffer fullness: %d metrics", nBuffer)
} else {
r.log.Debugf("Buffer fullness: %d / %d metrics", nBuffer, r.MetricBufferLimit)
}
}
func (r *RunningOutput) Log() telegraf.Logger {