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

Prevent select_jsonpath queries return empty list values. #17805

Closed
miwent opened this issue Dec 29, 2023 · 0 comments · Fixed by #18674
Closed

Prevent select_jsonpath queries return empty list values. #17805

miwent opened this issue Dec 29, 2023 · 0 comments · Fixed by #18674
Assignees

Comments

@miwent
Copy link
Contributor

miwent commented Dec 29, 2023

Expected Behavior

To have the option to remove empty list results from the paths output of select_jsonpath.

Current Behavior

Empty list values are returned from all select_jsonpath path queries when there are no query results.

Possible Solution

Add an optional setting for the select_jsonpath function to remove empty list values.

Steps to Reproduce (for bugs)

Use the following rule in the pipeline simulator with any message:

rule "testing select_jsonpath"
when
    true
then
    let json_msg = "{ \"json_array\":[{\"name\":\"obj_a\",\"value\":\"val_a\"}], \"blah\": \"blah\" }";
    
    let json_parsed = parse_json ( to_string ( json_msg ) );
        
    let paths = select_jsonpath (
        json: json_parsed,
        paths: {
            example_a: "$.blah",
            example_b: "$.nothing",
            exmaple_c: "$.[?(@.json_array)]..name",
            example_d: "$.[?(@.nothing)]..value"
            }
        );

    set_fields (
        fields: paths
        );

end

The results will be:
image

There is no "example_b" field (there is no root key by that name) but that example_d exists and is an empty list.

Context

Processing JSON event log messages from complex sources such as Office 365 and Okta leads to using the select_jsonpath with many path options, using path queries, to account for many different conditions.

Currently this leads to adding a stage of processing with multiple rules just to identify and remove empty query results. While it may sometimes be desirable to have these empty list values, the majority of the time this just leads to a large number of additional rules that exist only to remove the empty list vales in certain conditions.

Your Environment

  • Graylog Version: 5.1.6
  • Java Version: openjdk version "17.0.9" 2023-10-17
  • OpenSearch Version:
  • MongoDB Version:
  • Operating System: Ubuntu 20.04.6 LTS
  • Browser version: Firefox 120.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants