From 790c21e7cd2e10087bb76319787e87bbe6537ede Mon Sep 17 00:00:00 2001 From: Dane Strandboge <136023093+DStrand1@users.noreply.github.com> Date: Tue, 30 Jul 2024 03:18:10 -0500 Subject: [PATCH] fix(agent): Fix buffer directory config and document (#15661) --- config/config.go | 9 +++++---- docs/CONFIGURATION.md | 7 ++++++- models/running_output.go | 6 +++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 20795a218..07597897b 100644 --- a/config/config.go +++ b/config/config.go @@ -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", diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 58c6b58b1..c50956aa8 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -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 diff --git a/models/running_output.go b/models/running_output.go index 1f9c9a923..795b76a45 100644 --- a/models/running_output.go +++ b/models/running_output.go @@ -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 {