Skip to content

Update select_jsonpath to accept strings of JSON in addition to JsonNode objects#17683

Merged
ryan-carroll-graylog merged 5 commits into
masterfrom
17647-select_jsonpath-pipeline-function-only-works-in-same-rule-where-parse_json-was-used
Dec 15, 2023
Merged

Update select_jsonpath to accept strings of JSON in addition to JsonNode objects#17683
ryan-carroll-graylog merged 5 commits into
masterfrom
17647-select_jsonpath-pipeline-function-only-works-in-same-rule-where-parse_json-was-used

Conversation

@ryan-carroll-graylog

@ryan-carroll-graylog ryan-carroll-graylog commented Dec 13, 2023

Copy link
Copy Markdown
Contributor

Description

Previously select_jsonpath could only be used with a parsed JsonNode object (e.g. the direct output of parse_json within the same rule).

This update allows the select_jsonpath function to accept a JSON String as the json parameter as well.

Closes: #17647

Motivation and Context

As it stands:
We can use parse_json and select_jsonpath to work with JSON, but currently, the select_jsonpath function only works within the same rule where parse_json was originally used. If the output from parse_json is saved as a field on the message, select_jsonpath calls in subsequent rules on that field will fail.

This update allows a saved JSON message field to be used as the select_jsonpath json parameter.

How Has This Been Tested?

Locally in dev environment and unit tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

…ly-works-in-same-rule-where-parse_json-was-used
@ryan-carroll-graylog ryan-carroll-graylog marked this pull request as ready for review December 14, 2023 15:09

@danotorrey danotorrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works great and adds really nice flexibility! Well done @ryan-carroll-graylog!

Comment thread changelog/unreleased/issue-17647.toml Outdated

@kingzacko1 kingzacko1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just fix the changelog issue and pulls but it all looks good!

Co-authored-by: Zack King <91903901+kingzacko1@users.noreply.github.com>
@ryan-carroll-graylog ryan-carroll-graylog merged commit be7df67 into master Dec 15, 2023
@ryan-carroll-graylog ryan-carroll-graylog deleted the 17647-select_jsonpath-pipeline-function-only-works-in-same-rule-where-parse_json-was-used branch December 15, 2023 19:11
ryan-carroll-graylog added a commit that referenced this pull request Jan 10, 2024
…ode 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 <91903901+kingzacko1@users.noreply.github.com>

---------

Co-authored-by: Zack King <91903901+kingzacko1@users.noreply.github.com>
ryan-carroll-graylog added a commit that referenced this pull request Jan 10, 2024
…ode 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 <91903901+kingzacko1@users.noreply.github.com>

---------

Co-authored-by: Zack King <91903901+kingzacko1@users.noreply.github.com>
ryan-carroll-graylog added a commit that referenced this pull request Jan 11, 2024
* 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 <91903901+kingzacko1@users.noreply.github.com>

---------

Co-authored-by: Zack King <91903901+kingzacko1@users.noreply.github.com>

* 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 <91903901+kingzacko1@users.noreply.github.com>
ryan-carroll-graylog added a commit that referenced this pull request Jan 11, 2024
…ode objects (#17683) (#17896)

* 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 <91903901+kingzacko1@users.noreply.github.com>
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.

select_jsonpath pipeline function only works in same rule where parse_json was used

3 participants