From e3a8d202acd6a98dc460fb149f698a24907c7e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:15:04 +0100 Subject: [PATCH] Adjust Influxdb buffering as we have experienced silent package drops. This issue is not fixed, it is just made less probable. --- pkg/monitoring/influxdb2_middleware.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/monitoring/influxdb2_middleware.go b/pkg/monitoring/influxdb2_middleware.go index e77a31d..aecd78e 100644 --- a/pkg/monitoring/influxdb2_middleware.go +++ b/pkg/monitoring/influxdb2_middleware.go @@ -57,18 +57,21 @@ func InitializeInfluxDB(db *config.InfluxDB) (cancel func()) { return func() {} } + // How often to retry to write data. + const maxRetries = 50 // How long to wait before retrying to write data. - const retryInterval = 30 * time.Second + const retryInterval = 5 * time.Second // How old the data can be before we stop retrying to write it. Should be larger than maxRetries * retryInterval. const retryExpire = 10 * time.Minute - // How often to retry to write data. - const maxRetries = 10 + // How many batches are buffered before dropping the oldest. + const retryBufferLimit = 100_000 // Set options for retrying with the influx client. options := influxdb2.DefaultOptions() options.SetRetryInterval(uint(retryInterval.Milliseconds())) options.SetMaxRetries(maxRetries) options.SetMaxRetryTime(uint(retryExpire.Milliseconds())) + options.SetRetryBufferLimit(retryBufferLimit) // Create a new influx client. client := influxdb2.NewClientWithOptions(db.URL, db.Token, options)