Skip to content
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

[Libbeat] Fix array matching in contains condition #11691

Merged
merged 4 commits into from
Apr 10, 2019

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Apr 8, 2019

Matching arrays of strings inside a contains condition doesn't work properly with the output of JSON decoding as it is expecting fields of type []string when they are in this case []interface{}.

It outputs the following error:
2019-04-08T12:10:31.866+0200 WARN [conditions] conditions/matcher.go:97 unexpected type []interface {} in contains condition as it accepts only strings.

Fixes: #3138

Matching arrays of strings inside a `contains` condition doesn't work
properly as it is expecting fields of type `[]string` when they are in
fact `[]interface{}`.
@adriansr adriansr requested a review from a team as a code owner April 8, 2019 10:11
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix #3138?

@@ -86,7 +86,7 @@ func (c Matcher) Check(event ValuesMap) bool {
return false
}

case []string:
case []interface{}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What events were you seeing where it had []interface{} rather than []string? I assume this code would need to handle both data types. My guess is that []interface{} is found in data parsed by Filebeat and that []string is found in events that are natively generated in a Beat (such as a list of tags).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely right. Thanks. I got confused with maps from decoders where arrays are always of type []interface{}.

@adriansr
Copy link
Contributor Author

adriansr commented Apr 9, 2019

@andrewkroh yes, this is the issue reported in #3138

@adriansr adriansr merged commit 6a56dad into elastic:master Apr 10, 2019
@adriansr adriansr deleted the fix_lb_contains_condition branch April 10, 2019 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants