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

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

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading