Skip to content

Commit

Permalink
fix(agent): Fix buffer directory config and document (#15661)
Browse files Browse the repository at this point in the history
  • Loading branch information
DStrand1 authored Jul 30, 2024
1 parent fe7321e commit 790c21e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion models/running_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 790c21e

Please sign in to comment.