Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix bug in the Syslog input that misparsed rfc5424 days starting with 0. {pull}26419[26419]
- Do not close filestream harvester if an unexpected error is returned when close.on_state_change.* is enabled. {pull}26411[26411]
- Fix Elasticsearch compatibility for modules that use `copy_from` in `set` processors. {issue}26629[26629]
- Change type of max_bytes in all configs to be cfgtype.ByteSize {pull}26699[26699]

*Filebeat*

Expand Down
5 changes: 3 additions & 2 deletions libbeat/reader/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/dustin/go-humanize"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/cfgtype"
"github.com/elastic/beats/v7/libbeat/reader"
"github.com/elastic/beats/v7/libbeat/reader/multiline"
"github.com/elastic/beats/v7/libbeat/reader/readfile"
Expand All @@ -43,7 +44,7 @@ type Parser interface {
}

type CommonConfig struct {
MaxBytes int `config:"max_bytes"`
MaxBytes cfgtype.ByteSize `config:"max_bytes"`
LineTerminator readfile.LineTerminator `config:"line_terminator"`
}

Expand Down Expand Up @@ -126,7 +127,7 @@ func (c *Config) Create(in reader.Reader) Parser {
if err != nil {
return p
}
p, err = multiline.New(p, "\n", c.pCfg.MaxBytes, &config)
p, err = multiline.New(p, "\n", int(c.pCfg.MaxBytes), &config)
if err != nil {
return p
}
Expand Down
31 changes: 30 additions & 1 deletion libbeat/reader/parser/parser_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"github.com/stretchr/testify/require"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/cfgtype"
"github.com/elastic/beats/v7/libbeat/reader/readfile"
)

type inputParsersConfig struct {
MaxBytes int `config:"max_bytes"`
MaxBytes cfgtype.ByteSize `config:"max_bytes"`
LineTerminator readfile.LineTerminator `config:"line_terminator"`
Parsers Config `config:",inline"`
}
Expand Down Expand Up @@ -70,6 +71,34 @@ func TestParsersExampleInline(t *testing.T) {
"[log] In total there should be 3 events\n",
},
},
"humanize max_bytes, multiline XML": {
lines: `<Event><Data>
A
B
C</Data></Event>
<Event><Data>
D
E
F</Data></Event>
`,
parsers: map[string]interface{}{
"max_bytes": "4 KiB",
"line_terminator": "auto",
"parsers": []map[string]interface{}{
map[string]interface{}{
"multiline": map[string]interface{}{
"match": "after",
"negate": true,
"pattern": "^<Event",
},
},
},
},
expectedMessages: []string{
"<Event><Data>\n\n\tA\n\n\tB\n\n\tC</Data></Event>\n",
"<Event><Data>\n\n\tD\n\n\tE\n\n\tF</Data></Event>\n",
},
},
}

for name, test := range tests {
Expand Down