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

aws-s3 input default content-type #25772

Merged
merged 3 commits into from
May 19, 2021

Conversation

leehinman
Copy link
Contributor

@leehinman leehinman commented May 18, 2021

What does this PR do?

Adds a new option content_type to the aws-s3 input. This allows you
to override the Content-Type that was given to the S3 object when it
was uploaded.

Why is it important?

Content-Type is used to determine if the S3 object should be treated
as JSON or not. If the object was uploaded with the incorrect
Content-Type that can prevent us from parsing the file correctly.

Checklist

  • My code follows the style guidelines of this project
    - [ ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

How to test this PR locally

Setup SQS and S3 bucket and download files.

Related issues

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 18, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 18, 2021
- new option `content_type`
- can be set at input or file selector level
- overrides Content-Type that was given to the S3 object when it was
  uploaded.

Closes elastic#25697
@leehinman leehinman force-pushed the 25697_awss3_fallback_content_type branch from a286ff5 to 87f4f26 Compare May 18, 2021 19:37
@leehinman leehinman requested a review from andrewkroh May 18, 2021 19:39
@elasticmachine
Copy link
Collaborator

elasticmachine commented May 18, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #25772 updated

  • Start Time: 2021-05-19T03:49:22.179+0000

  • Duration: 114 min 35 sec

  • Commit: 1004e17

Test stats 🧪

Test Results
Failed 0
Passed 7139
Skipped 1193
Total 8332

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 7139
Skipped 1193
Total 8332

Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -82,6 +83,9 @@ func (f *readerConfig) Validate() error {
if f.MaxBytes <= 0 {
return fmt.Errorf("max_bytes <%v> must be greater than 0", f.MaxBytes)
}
if f.ExpandEventListFromField != "" && f.ContentType != "" && f.ContentType != "application/json" {
return fmt.Errorf("content_type must be `application/json` to be used with expand_event_list_from_field")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("content_type must be `application/json` to be used with expand_event_list_from_field")
return fmt.Errorf("content_type must be `application/json` when expand_event_list_from_field is used")

Just a suggestion

@leehinman leehinman merged commit d62b1be into elastic:master May 19, 2021
mergify bot pushed a commit that referenced this pull request May 19, 2021
* aws-s3 input default content-type

- new option `content_type`
- can be set at input or file selector level
- overrides Content-Type that was given to the S3 object when it was
  uploaded.

Closes #25697

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
(cherry picked from commit d62b1be)
leehinman added a commit that referenced this pull request May 19, 2021
* aws-s3 input default content-type

- new option `content_type`
- can be set at input or file selector level
- overrides Content-Type that was given to the S3 object when it was
  uploaded.

Closes #25697

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
(cherry picked from commit d62b1be)

Co-authored-by: Lee Hinman <57081003+leehinman@users.noreply.github.com>
@leehinman leehinman deleted the 25697_awss3_fallback_content_type branch August 17, 2021 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.14.0 Automated backport with mergify enhancement Filebeat Filebeat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

S3 input: Add fallback configuration for content type so that events can be decoded
4 participants