-
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
Add multiline.flush_pattern option #4019
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
I have signed the CLA now.. can somebody trigger it to check again? :) |
ahhr... need to run it through gofmt... will fix and amend |
5f38605
to
732d816
Compare
@TheoAndersen Thanks a lot for the contribution. I' m thinking if we should have a separate config option for start and end/flush pattern so we don't mix it with the other configs. The part I worry is that "misconfiguration" of all together could lead to strange side effects. At the same time the implementation looks rather simple you did
|
@ruflin Thanks for the comments. This PR is just the addition of the extra optional parameter One thing i have found though, is that the way i use this multiline configuration will force everything to be gathered into events - wheres i really just wanted to merge specific lines (matched with a start and end pattern) into a single event - and leave the rest as they are. Ex if you have a log like this
and use a configuration like this
then it will create 3 events.
Where i really only wanted line 3 to 5 merged. I'm not sure if this is possible to do, by continuing to hack or add on the current multiline implementation? using the Do you have any suggestions for this? Also i would ideally like to be able to specify multiple start-end patterns, if there was multiple kinds of events in there (but this could be done by piping in the regular expression i guess). |
I feel like this PR is a good kick of to discuss how we should extend multiline and which use cases it should covered. Unfortunately the initial design doc is now in the filebeat repo which we made private to not have people opening issues there all the time. But in summary there are 2 things in there which we haven't implemented yet:
What you implemented here is kind of the end pattern, but I agree with you that I would also expect the behaviour that one event for each line is sent, if no start pattern is started. The initial implementation was done based on some example logs from java stack traces to json logs etc. I would suggest we proceed like this and having directly some real world examples that we want to work on. Perhaps what you did above is already all we need as the other format is more a theoretical one, but not sure. One of the suggestion from the "old" issue looks as following:
This can probably be expressed in more compact way. |
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.
We quickly discussed this internally and decided to move forward with this and add more feature to multiline at a later stage. This already solves lots of potential use cases.
I suggest we add a few system-tests to the mix (check tests/system/test_multiline.py) to make sure the behaviour is exactly as expected.
Could you also add a changelog entry?
@@ -60,16 +60,20 @@ func TestMultilineAfterNegateOK(t *testing.T) { | |||
) | |||
} | |||
|
|||
func TestMultilineBeforeNegateOK(t *testing.T) { |
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.
We should not overwrite an existing test but add a new one.
732d816
to
1287606
Compare
This should have added the missing test, and the changelog |
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. I left you two minor comments.
// handle case when endPattern is reached | ||
if mlr.flushMatcher != nil { | ||
endPatternReached := (mlr.flushMatcher.Match(message.Content)) | ||
// fmt.Println("Next line: " + string(message.Content)) |
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.
this line should be removed.
flushMatcher := match.MustCompile(`EventEnd`) | ||
|
||
testMultilineOK(t, | ||
MultilineConfig{ |
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 you add one more test where first there are lines which do not match the pattern EventStart
?
adc6097
to
31a8a5c
Compare
Can anybody help me with this build-error? Can't seem to figure it out ( @ruflin? ) |
@TheoAndersen Bad timing. There was one commit today which was merged into master and was failing and you exactly got that one :-( Can you rebase on top of master and run |
31a8a5c
to
2b5150f
Compare
Thats how it goes. Trying again :) |
jenkins, test it |
Was that just thinking out loud, or does jenkins actually parse these comments? if so.. Jenkins, test faster ;o) |
Yes, jenkins parses the comments, but there are only a few and not all users can trigger the events ;-) |
CHANGELOG.asciidoc
Outdated
@@ -343,6 +343,12 @@ https://github.com/elastic/beats/compare/v5.2.2...v5.3.0[View commits] | |||
- The `symlinks` and `harverster_limit` settings are now GA, instead of experimental. {pull}3525[3525] | |||
- close_timeout is also applied when the output is blocking. {pull}3511[3511] | |||
- Improve handling of different path variants on Windows. {pull}3781[3781] | |||
- Restructure input.Event to be inline with outputs.Data {pull}3823[3823] |
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.
Sorry to bug you again, but this seems to have been messed up during rebasing. Unfortunately happens from time to time :-(
All good from my side and ready to merge as soon as changelog is updated. |
This allows for specifying a regex, which will flush the current multiline, thus ending the current multiline. Useful for using multiline to capture application events with 'start' and 'end' lines. Example configuration multiline.pattern: 'start' multiline.negate: true multiline.match: after multiline.flush_pattern: 'end' (elastic#3964)
2b5150f
to
334150a
Compare
Updated changelog |
@TheoAndersen Merged. Thanks a lot for this contribution. |
The changelog indicates that this feature is available in 5.3.0 and above. https://github.com/elastic/beats/blob/master/CHANGELOG.asciidoc#beats-version-530 But the actual code does not appear until 6.0. Should we fix the changelog? @ruflin |
@ppf2 It definitively seems like this changelog ended up in the completely wrong place. @monicasarbu @tsg What should we do here as I remember our CHANGELOG is also in some release etc. I assume it's not solved by just removing it in 5.x. |
This allows for specifying a regex, which will flush the current multiline, thus ending the current multiline. Useful for using multiline to capture application events with 'start' and 'end' lines.
Example configuration
multiline.pattern: 'start'
multiline.negate: true
multiline.match: after
multiline.flush_pattern: 'end'
(#3964)