From d0c9d8df3460827aa3a8c7cb83df8f773fcfaf46 Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Tue, 7 Sep 2021 15:38:26 -0400 Subject: [PATCH] Update force flush default (#261) * Increase default flush period * Update tests * Update doc * Update for consistency --- docs/operators/file_input.md | 2 +- operator/builtin/input/file/config_test.go | 4 ++++ operator/helper/multiline.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/operators/file_input.md b/docs/operators/file_input.md index c3a1c6052943..93759061e0dc 100644 --- a/docs/operators/file_input.md +++ b/docs/operators/file_input.md @@ -12,7 +12,7 @@ The `file_input` operator reads logs from files. It will place the lines read in | `exclude` | [] | A list of file glob patterns to exclude from reading | | `poll_interval` | 200ms | The duration between filesystem polls | | `multiline` | | A `multiline` configuration block. See below for details | -| `force_flush_period` | `0s` | Time since last read of data from file, after which currently buffered log should be send to pipeline. Takes [duration](../types/duration.md) as value. Zero means waiting for new data forever | +| `force_flush_period` | `500ms` | Time since last read of data from file, after which currently buffered log should be send to pipeline. Takes [duration](../types/duration.md) as value. Zero means waiting for new data forever | | `write_to` | `$body` | The body [field](/docs/types/field.md) written to when creating a new log entry | | `encoding` | `utf-8` | The encoding of the file being read. See the list of supported encodings below for available options | | `include_file_name` | `true` | Whether to add the file name as the attribute `file.name` | diff --git a/operator/builtin/input/file/config_test.go b/operator/builtin/input/file/config_test.go index f97262344710..98125e214137 100644 --- a/operator/builtin/input/file/config_test.go +++ b/operator/builtin/input/file/config_test.go @@ -706,6 +706,7 @@ func TestMapStructureDecodeConfigWithHook(t *testing.T) { "line_start_pattern": expect.Splitter.Multiline.LineStartPattern, "line_end_pattern": expect.Splitter.Multiline.LineEndPattern, }, + "force_flush_period": 0.5, "include_file_name": true, "include_file_path": false, "start_at": "end", @@ -749,6 +750,9 @@ func TestMapStructureDecodeConfig(t *testing.T) { "max_log_size": 1024 * 1024, "max_concurrent_files": 1024, "encoding": "utf16", + "force_flush_period": map[string]interface{}{ + "Duration": 500 * 1000 * 1000, + }, } var actual InputConfig diff --git a/operator/helper/multiline.go b/operator/helper/multiline.go index ff1daf4d9f5e..af822d1ac76f 100644 --- a/operator/helper/multiline.go +++ b/operator/helper/multiline.go @@ -33,7 +33,7 @@ type FlusherConfig struct { func NewFlusherConfig() FlusherConfig { return FlusherConfig{ // Empty or `0s` means that we will never force flush - Period: Duration{Duration: 0}, + Period: Duration{Duration: time.Millisecond * 500}, } }