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

Expand_keys doesn’t work if target option is used in decode_json_fields beat processor #31712

Closed
iorfix opened this issue May 23, 2022 · 3 comments · Fixed by #32010
Closed
Assignees
Labels
bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Comments

@iorfix
Copy link

iorfix commented May 23, 2022

In decode_json_fields processor, expanded notation works only if target is left to "".
In fact, in source code ( beats/decode_json_fields.go at master · elastic/beats · GitHub ) there is a clear if section:

if target != "" {
	_, err = event.PutValue(target, output)
} else {
	switch t := output.(type) {
	case map[string]interface{}:
	    jsontransform.WriteJSONKeys(event, t, f.expandKeys, f.overwriteKeys, f.addErrorKey)
	default:
  	    errs = append(errs, "failed to add target to root")
	}
}

According to https://discuss.elastic.co/t/expand-keys-doesnt-work-if-target-option-is-used-in-decode-json-fields-beat-processor/305276 this is a bug

  1. Add the following section in filebeat.yml on the same node of a running elasticsearch instance with xpack audit enabled.
  2. Verify that some fields (e.g. user.name, or event.action) are not "de-dotted", but json is a flat structure
- type: filestream
  id: audit_elasticsearch
  enabled: true
  paths:
    - /var/log/elasticsearch/mycluster_audit.json
  processors:
    - decode_json_fields:
        fields: message
        max_depth: 8
        expand_keys: true
        overwrite_keys: False
        target: json
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 23, 2022
@kvch kvch added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label May 24, 2022
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 24, 2022
@kvch kvch added bug needs_team Indicates that the issue/PR needs a Team:* label labels May 24, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 24, 2022
@botelastic
Copy link

botelastic bot commented May 24, 2022

This issue doesn't have a Team:<team> label.

@nixfloyd
Copy link

Folks, this is still an issue in latest 7.17.x, looks like the change has not been backported, e.g:
#32014 did not get merged

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

Successfully merging a pull request may close this issue.

4 participants