-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Backport 5.2) - Pipeline function json handling improvements (#17895)
* Update select_jsonpath to accept strings of JSON in addition to JsonNode objects (#17683) * Update select_jsonpath to accept strings of JSON in addition to JsonNode objects * Add unit test * Add changelog entry * Update changelog with correct issue/pr Co-authored-by: Zack King <[email protected]> --------- Co-authored-by: Zack King <[email protected]> * Add handling for json arrays in lookup_all pipeline function (#17820) * Add handling for json arrays in lookup_all pipeline function * Add changelog entry * Update failing tests * Revert unneeded non string functionality * Update changelog * Cleanup test --------- Co-authored-by: Zack King <[email protected]>
- Loading branch information
1 parent
31583a0
commit 782a5d6
Showing
7 changed files
with
148 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "c" | ||
message = "Updated the select_jsonpath pipeline function to accept JSON strings as the `json` parameter in addition to parsed JsonNode objects." | ||
|
||
issues = ["17647"] | ||
pulls = ["17683"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "fixed" | ||
message = "Fix issue preventing the lookup_all pipeline function from working with json arrays" | ||
|
||
issues = ["graylog-plugin-enterprise#6363"] | ||
pulls = ["17820"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...st/resources/org/graylog/plugins/pipelineprocessor/functions/jsonpathFromMessageField.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
rule "jsonpathFromMessageField" | ||
when | ||
is_json(parse_json("{}")) == true && | ||
is_json("foobar") == false && | ||
is_json(1234) == false && | ||
is_json(12.34) == false && | ||
is_json(true) == false | ||
then | ||
let new_fields = select_jsonpath($message.message, | ||
{ author_first: "$['store']['book'][0]['author']", | ||
author_last: "$['store']['book'][-1:]['author']" | ||
}); | ||
set_fields(new_fields); | ||
|
||
// Don't fail on empty input | ||
let invalid_json = parse_json("#FOOBAR#"); | ||
let invalid_json_fields = select_jsonpath(invalid_json, { some_field: "$.message" }); | ||
set_fields(invalid_json_fields); | ||
|
||
// Don't fail on missing field | ||
let missing_fields = select_jsonpath($message.message, { some_field: "$.i_dont_exist", this_should_exist: "$['store']['book'][-1:]['author']" }); | ||
set_fields(missing_fields); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters