-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Filebeat] Add basic json support into s3 input #15370
Conversation
We need a way to be able to tell it to iterate over nested objects and create one document per object. Like if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with cloudtrail and it worked for both single event in Records array and multiple events in Records array. :-)
I did see a panic if json.message_key: Records
wasn't included with Cloudtrail S3 input.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x571a5e8]
goroutine 259 [running]:
github.com/elastic/beats/x-pack/filebeat/input/s3.(*s3Input).handleS3Objects(0xc000118000, 0x618c820, 0xc0007f6010, 0xc0007e5e80, 0x1, 0x1, 0xc00005a420, 0x0, 0x0)
/go/src/github.com/elastic/beats/x-pack/filebeat/input/s3/input.go:384 +0xa98
github.com/elastic/beats/x-pack/filebeat/input/s3.(*s3Input).processMessage(0xc000118000, 0x618c820, 0xc0007f6010, 0x0, 0xc000946020, 0xc000946050, 0x0, 0x0, 0xc000946080, 0xc0009460c0, ...)
/go/src/github.com/elastic/beats/x-pack/filebeat/input/s3/input.go:257 +0x2f6
created by github.com/elastic/beats/x-pack/filebeat/input/s3.(*s3Input).processor
/go/src/github.com/elastic/beats/x-pack/filebeat/input/s3/input.go:240 +0x19c
@andrewkroh Thanks for the review. With this PR, if |
@leehinman Thanks for testing it! Panic bug is fixed now! |
I dont think CI failures are related. Merging this PR. |
This PR is to add basic json support for s3 input so the work of adding cloudtrail metricset can continue.
expand_event_list_from_field
is added in s3 input config for users to specify the top level key name in the JSON object. For example, in cloudtrail log example below,Records
should be theexpand_event_list_from_field
in order for s3 input to parse the log correctly.This PR is only for adding
expand_event_list_from_field
to implement #15357cloudtrail log example:
How to test this
In order to get json log files into S3 bucket, you can manually upload json file or you can enable cloudtrail log in AWS to send logs to a specific S3 bucket.
Also you need to create an SQS queue and setup notifications for any new object created in S3 bucket.
Run filebeat with s3 input enabled in filebeat.yml:
This will enable Filebeat s3 input to parse json logs.
Output