diff --git a/docs/INPUTS.md b/docs/INPUTS.md index 029a1d568..650f9ac41 100644 --- a/docs/INPUTS.md +++ b/docs/INPUTS.md @@ -87,6 +87,9 @@ Metric Tracking provides a system to be notified when metrics have been successfully written to their outputs or otherwise discarded. This allows inputs to be created that function as reliable queue consumers. +Please note that this process applies only to internal plugins. For external +plugins, the metrics are acknowledged regardless of the actual output. + To get started with metric tracking begin by calling `WithTracking` on the [telegraf.Accumulator][]. Add metrics using the `AddTrackingMetricGroup` function on the returned [telegraf.TrackingAccumulator][] and store the diff --git a/docs/METRICS.md b/docs/METRICS.md index f626195a6..8ec182348 100644 --- a/docs/METRICS.md +++ b/docs/METRICS.md @@ -34,6 +34,9 @@ before telling the metric source that the message was read. If Telegraf were to stop or the system running Telegraf to crash, this allows the messages that were not completely delivered to an output to get re-read at a later date. +Please note that this process applies only to internal plugins. For external +plugins, the metrics are acknowledged regardless of the actual output. + ### Undelivered Messages When an input uses tracking metrics, an additional setting, diff --git a/plugins/common/shim/goshim.go b/plugins/common/shim/goshim.go index 60ad5e84f..72af49dda 100644 --- a/plugins/common/shim/goshim.go +++ b/plugins/common/shim/goshim.go @@ -115,13 +115,16 @@ func (s *Shim) writeProcessedMetrics() error { } b, err := serializer.Serialize(m) if err != nil { + m.Reject() return fmt.Errorf("failed to serialize metric: %w", err) } // Write this to stdout _, err = fmt.Fprint(s.stdout, string(b)) if err != nil { + m.Drop() return fmt.Errorf("failed to write metric: %w", err) } + m.Accept() } } }