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

add json support via expr helpers #25

Merged
7 commits merged into from May 25, 2020
Merged

add json support via expr helpers #25

7 commits merged into from May 25, 2020

Conversation

buixor
Copy link
Contributor

@buixor buixor commented May 22, 2020

  • Add a method to allow extraction of one or more field from json JsonExtract(evt.Parsed.Field, "my.sub_field.json[0]")
  • Add unit test for json extraction

@AlteredCoder
Copy link
Contributor

I would have called the function only JSON() or Json() instead of JsonExtract()

@buixor
Copy link
Contributor Author

buixor commented May 25, 2020

@AlteredCoder : I'm afraid calling it "only" Json or JSON might be confusing, maybe we can find a middle ground :)

@buixor buixor changed the title [wip] add json support via expr helpers add json support via expr helpers May 25, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I didn't see the json file used for the test. Can you point me this file ?

pkg/exprhelpers/jsonextract.go Outdated Show resolved Hide resolved

func matchEvent(expected types.Event, out types.Event, debug bool) ([]string, bool) {
var retInfo []string
var valid bool
Copy link

Choose a reason for hiding this comment

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

var valid = false but not mandatory because it's the zero value

valid = false
goto checkFinished
} else {
valid = true
Copy link

Choose a reason for hiding this comment

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

The tool reporting this linter error, has the pretention to not display false positive. But from what I see it is a false positive.

pkg/parser/parsing_test.go Show resolved Hide resolved
@buixor
Copy link
Contributor Author

buixor commented May 25, 2020

I didn't see the json file used for the test. Can you point me this file ?

They are in pkg/parser/tests/base-json-extract and represent a scenario where we extract first from json and then apply grok patterns on it.

@ghost ghost merged commit 060a595 into master May 25, 2020
@ghost ghost deleted the json_extractor branch May 25, 2020 09:47
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants