Added support for TCP octet-counting framing - #83
Conversation
Changelog and Version ManagementNo changelog or version changes detected. You can either update them manually or use a comment command to update them automatically on merge:
Omit the entry line to use the PR title. If multiple commands are posted, the last one wins. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Logstash syslog input plugin to support RFC 6587 transparent framing (octet-counting) for TCP syslog ingestion, and bumps the plugin version/documentation accordingly.
Changes:
- Add octet-counting (transparent framing) logic to
tcp_read_linesfor TCP inputs. - Bump plugin version to
3.8.0and add a changelog entry for the new feature. - Update plugin documentation to mention TCP framing and link to RFC 6587.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
version |
Bumps plugin version to 3.8.0. |
lib/logstash/inputs/syslog.rb |
Implements transparent-framing parsing in the TCP read loop. |
docs/index.asciidoc |
Documents TCP framing support and adds RFC 6587 reference. |
CHANGELOG.md |
Adds a 3.8.0 entry describing transparent framing support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| end | ||
| end | ||
| end | ||
| if buffer[0].match?(/\d/) #Check if the first char is a digit |
There was a problem hiding this comment.
Could not find information supporting this, tests are passing without issue and I do not understand why adding an anchor would help.
| buffer << socket.read_nonblock(16) | ||
| first_space = buffer.index(" ") | ||
| log_len = Integer(buffer.slice!(0..first_space)) | ||
| buffer << socket.read_nonblock(log_len-buffer.length) | ||
| yield buffer.slice!(0..log_len) |
| if buffer[0].match?(/\d/) #Check if the first char is a digit | ||
| loop do | ||
| begin | ||
| buffer << socket.read_nonblock(16) | ||
| first_space = buffer.index(" ") | ||
| log_len = Integer(buffer.slice!(0..first_space)) |
| This input also supports both transparent and non-transparent TCP framing.. | ||
|
|
||
| For more information see the http://www.ietf.org/rfc/rfc3164.txt[RFC3164 page]. | ||
| For more information on syslog see the http://www.ietf.org/rfc/rfc3164.txt[RFC3164 page] and for more information on TCP framing see the https://www.ietf.org/rfc/rfc6587.txt[RFC 6587 page]. |
|
Will have a deeper look at the PROXY and the |
|
Hello,
Intro
First time creating a PR so I'm prepared to having to redo it until it's fit this repo standards.
I've signed the CLA.
PR Goal
My goal with this PR is to allow the syslog input plugin to support receiving logs from assets using transparent framing, also called octet counting, as it is described in the RFC 6587 section 3.4.1.
Changes
I tinkered with the tcp_read_lines function and added a check.
If the first character in a buffer is a number, it will proceed with reading the first 16 chars (arbitrary number to make sure to capture the number of bytes in the log while not reading too much) and cut at the first space. The space is the delimiter specified in RFC 6587.
It will then read the next
log_lenamount of bytes minus the bytes that remained in the buffer and yield the result for processing.If the first char is not a digit, the handling of the log does not change, looking for the "\n" to cut off the log.
Limitations
This PR was written with the assumption that the logs were sent in good faith and that the bytes in the header do represent the length of the log. If the byte count at the start of the log is wrong, logs will be truncated / malformed and the input may crash and restart.