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

[filebeat] Add CSV decoder to httpjson input #28564

Merged
merged 3 commits into from
Oct 26, 2021

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Oct 20, 2021

What does this PR do?

Adds a text/csv decoder to the httpjson input.

Why is it important?

Some apis will only have the option to return csv content, which we want to convert to several events.

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.

@marc-gr marc-gr added enhancement Team:Security-External Integrations backport-skip Skip notification from the automated backport with mergify labels Oct 20, 2021
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Oct 20, 2021
@marc-gr
Copy link
Contributor Author

marc-gr commented Oct 20, 2021

/test

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2021

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b httpjson-csv-dec upstream/httpjson-csv-dec
git merge upstream/master
git push upstream httpjson-csv-dec

@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 20, 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 preview

Expand to view the summary

Build stats

  • Start Time: 2021-10-26T09:02:28.669+0000

  • Duration: 93 min 19 sec

  • Commit: 8be04d7

Test stats 🧪

Test Results
Failed 0
Passed 7775
Skipped 1201
Total 8976

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

@mtojek mtojek self-requested a review October 20, 2021 12:42
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Hmm, there are CI errors that look related to this PR. Did it work locally for you?

@leehinman
Copy link
Contributor

Not related to code, but I'm wondering if we should rename the input since we aren't getting json back? It just seems odd to get CSV from httpjson.

Also I'm thinking it might be a good idea to switch to something like the parsers config option that was added to the filestream input.

@marc-gr
Copy link
Contributor Author

marc-gr commented Oct 21, 2021

Not related to code, but I'm wondering if we should rename the input since we aren't getting json back? It just seems odd to get CSV from httpjson.

The input will return json, but this adds the ability to convert a CSV response from an API to a list of JSON objects. In any case, I am fine with the eventual renaming (to http maybe?), since this does more and more as time goes by.

Also I'm thinking it might be a good idea to switch to something like the parsers config option that was added to the filestream input.

You mean something that lets us add extra configuration to the parser/decoder? Or directly using parser.Config from libbeat as in filestream?

@leehinman
Copy link
Contributor

Not related to code, but I'm wondering if we should rename the input since we aren't getting json back? It just seems odd to get CSV from httpjson.

The input will return json, but this adds the ability to convert a CSV response from an API to a list of JSON objects. In any case, I am fine with the eventual renaming (to http maybe?), since this does more and more as time goes by.

I like http or http_client, be nice if http_endpoint got renamed to http_server or httpd for consistency.

Also I'm thinking it might be a good idea to switch to something like the parsers config option that was added to the filestream input.

You mean something that lets us add extra configuration to the parser/decoder? Or directly using parser.Config from libbeat as in filestream?

I was thinking it would be nice to to use something like the Reader interface that libbeat uses and to be able to stack them in a particular order like you can with parser config in filestream. So our code just calls Next and the reader knows how to do that. Then we could support things like new line delimited, fixed size, multiline, json, csv, etc..

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

We can worry about rename later.

@marc-gr marc-gr merged commit f6a696c into elastic:master Oct 26, 2021
@marc-gr marc-gr deleted the httpjson-csv-dec branch October 26, 2021 10:55
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
* Add CSV decoder to httpjson input

* Fix error check and test

* Make allocated map to the size of the header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants