-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Filebeat] add RFC6587 framing support #23724
Conversation
1a789c1
to
c623f22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The automatic detection should make this easy to use. I like the approach.
func SplitFunc(lineDelimiter []byte) bufio.SplitFunc { | ||
// SplitFunc allows to create a `bufio.SplitFunc` based on a framing & | ||
// delimiter provided. | ||
func SplitFunc(framing string, lineDelimiter []byte) bufio.SplitFunc { | ||
if len(lineDelimiter) == 0 { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this return an error for this case. Then the message can be constructed in this one place rather than in each input.
if len(lineDelimiter) == 0 { | ||
return nil | ||
} | ||
|
||
ld := []byte(lineDelimiter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason not to directly use lineDelimiter
?
filebeat/input/syslog/config.go
Outdated
@@ -48,6 +48,7 @@ var defaultConfig = config{ | |||
type syslogTCP struct { | |||
tcp.Config `config:",inline"` | |||
LineDelimiter string `config:"line_delimiter" validate:"nonzero"` | |||
Framing string `config:"framing"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be make into a type FramingType
that implements Validate() error
such that config unpacking will automatically validate the values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried that using type FramingType string
and when beats would start I'd get the following panic:
instance/beat.go:167 Failed due to panic. {"panic": "reflect.nameFrom: name too long: *************************************************************************
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to implement https://pkg.go.dev/github.com/elastic/go-ucfg#StringUnpacker. Another option is to make it a type FramingType uint8
and also implement Unpack
(that's probably more common in the codebase than having the type be a string
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help. Is there any benefit to doing Validate() if Unpack() does validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. If the type itself has Unpack then no need to add another Validate step with similar logic.
- Adds new config option "framing" - supported options are "delimiter" & rfc6587 - delimiter is current option of newline or custom character(s) delimiter - rfc6587 adds support for octet counting and non-transparent framing as described in RFC6587 - rfc6587 supports changing of framing on a frame by frame basis - Default is "delimiter" Closes elastic#23663
86daa43
to
1f52de4
Compare
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
|
Test | Results |
---|---|
Failed | 0 |
Passed | 12908 |
Skipped | 2033 |
Total | 14941 |
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- Adds new config option "framing" - supported options are "delimiter" & rfc6587 - delimiter is current option of newline or custom character(s) delimiter - rfc6587 adds support for octet counting and non-transparent framing as described in RFC6587 - rfc6587 supports changing of framing on a frame by frame basis - Default is "delimiter" Closes elastic#23663 (cherry picked from commit 5cb370e)
- Adds new config option "framing" - supported options are "delimiter" & rfc6587 - delimiter is current option of newline or custom character(s) delimiter - rfc6587 adds support for octet counting and non-transparent framing as described in RFC6587 - rfc6587 supports changing of framing on a frame by frame basis - Default is "delimiter" Closes #23663 (cherry picked from commit 5cb370e)
What does this PR do?
Adds support for RFC6587 framing.
delimiter
as described in RFC6587
Why is it important?
Checklist
- [ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Related issues