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

ndjson parser doesn't expand keys if target is set #35628

Open
mjaepel opened this issue May 31, 2023 · 4 comments
Open

ndjson parser doesn't expand keys if target is set #35628

mjaepel opened this issue May 31, 2023 · 4 comments
Labels
bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Comments

@mjaepel
Copy link

mjaepel commented May 31, 2023

Hi,

it seems that there is the same issue with the ndjson parser like in the decode_json_fields processor some time ago: #32010

dotted fields aren't expanded if the target option in ndjson parser is set. All works fine if the target option is missing.
Seems to be this code position: https://github.com/elastic/beats/blob/main/libbeat/reader/readjson/json.go#L187

Example Filebeat config:

- type: filestream
  id: my_dummy_log
  paths:
    - /tmp/my_dummy_log
  parsers:
    - ndjson:
        target: 'dummy'
        expand_keys: true

Example data:

{ "my.test": 1 }

Expected event:

{ "dummy":  { "my": { "test": 1 } } }

But got event:

{ "dummy":  { "my.test": 1 } }

Tried with

- type: filestream
  id: my_dummy_log
  paths:
    - /tmp/my_dummy_log
  parsers:
    - ndjson:
        expand_keys: true

Then I get:

{ "my": { "test": 1 } }

It would be nice to get the old processor bug fix also for the ndjson parser.

Regards,
Marcel

For confirmed bugs, please report:

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 31, 2023
@botelastic
Copy link

botelastic bot commented May 30, 2024

Hi!
We just realized that we haven't looked into this issue in a while. We're sorry!

We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1.
Thank you for your contribution!

@botelastic botelastic bot added the Stalled label May 30, 2024
@belimawr belimawr added bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Oct 1, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed Stalled needs_team Indicates that the issue/PR needs a Team:* label labels Oct 1, 2024
@belimawr
Copy link
Contributor

belimawr commented Oct 1, 2024

I can confirm this is still an issue in our latest release, v8.15.2 and main branch.

@belimawr
Copy link
Contributor

belimawr commented Oct 1, 2024

The current workaround is to use the decode_json_fields processor, ex config:

- type: filestream
  id: my-filestream-id
  enabled: true
  paths:
    - /tmp/ex.ndjson
  processors:
    - decode_json_fields:
        fields:
          - message
        target: dummy
        expand_keys: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

No branches or pull requests

3 participants