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

fix chain call issue in HTTP JSON input #34325

Closed
wants to merge 31 commits into from

Conversation

kush-elastic
Copy link
Collaborator

@kush-elastic kush-elastic commented Jan 20, 2023

What does this PR do?

In HTTP JSON input of filebeat, chain calls were being executed and every response was collected first then they were published. So, it was using a lot of memory. Therefore filebeat was exiting without publishing any event.

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.

Related issues

Use cases

This PR contains changes to execute the publishing and collection of events concurrently. So, events will not be stored in memory while being collected and published later. Instead, events collection, processing, and publishing will be done simultaneously.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 20, 2023
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 20, 2023
@kush-elastic kush-elastic self-assigned this Jan 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Jan 20, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @kush-elastic? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 20, 2023

💚 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: 2023-07-10T06:48:40.745+0000

  • Duration: 76 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 3055
Skipped 178
Total 3233

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the 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.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@kush-elastic kush-elastic marked this pull request as ready for review February 2, 2023 18:06
@kush-elastic kush-elastic requested a review from a team as a code owner February 2, 2023 18:06
@elasticmachine
Copy link
Collaborator

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

@mergify
Copy link
Contributor

mergify bot commented Feb 3, 2023

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 httjson-chaincall-fix upstream/httjson-chaincall-fix
git merge upstream/main
git push upstream httjson-chaincall-fix

x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented Feb 7, 2023

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 httjson-chaincall-fix upstream/httjson-chaincall-fix
git merge upstream/main
git push upstream httjson-chaincall-fix

@kush-elastic kush-elastic requested a review from efd6 February 13, 2023 15:51
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

The invariant docs need to be in place, the diff is suggestion to consider.

x-pack/filebeat/input/httpjson/request.go Outdated Show resolved Hide resolved
@kush-elastic kush-elastic requested a review from efd6 February 14, 2023 13:42
@kush-elastic
Copy link
Collaborator Author

@kush-elastic can you resolve the conflicts so we can we go ahead and merge this ?

I have resolved the merge conflicts. let's wait for CI to pass.

@kush-elastic kush-elastic force-pushed the httjson-chaincall-fix branch from d62b116 to 853965a Compare June 13, 2023 10:30
@kush-elastic kush-elastic force-pushed the httjson-chaincall-fix branch from 853965a to 8f640f0 Compare June 13, 2023 10:44
@kush-elastic kush-elastic requested review from ShourieG and removed request for ShourieG June 16, 2023 05:25
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
@kush-elastic kush-elastic requested a review from efd6 July 10, 2023 05:33
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

LGTM after final nits.

x-pack/filebeat/input/httpjson/input_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ShourieG ShourieG left a comment

Choose a reason for hiding this comment

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

@kush-elastic after having gone through the code and having some internal discussions, this is certainly not a trivial change as it changes the fundamentals of chaining and how it functions. Since httpjson is used in most of our integrations we need to be extra careful in implementing major overhauls, so I kindly ask that the following be done :-

  1. Keep the old logic as a fallback that can be easily toggled on/off if the need arises, this is extremely important as it will help us avoid a lot of hassle and user outrage if something breaks-down at scale. This fallback can be removed later after the current code is stable for a while. This change is no-trivial and will possibly require a re-work of the logic. The fallback toggle could be done as part of the config as then it would be very easy to toggle it on/off.

  2. Maintain an official documentation detailing the changes to functionality in the current flow and add flow diagrams if necessary.

  3. Add more meaningful tests that uses data at scale/large amounts along with tests for the fallback mechanism also.

With these changes, I feel this PR would be ready to be merged.

@jamiehynds
Copy link

@kush-elastic is this non-trivial change purely related to Salesforce or are there other integrations that require this new approach to chained calls? Since this PR was originally raised, we've added a new CEL input, which may be a better fit for this use case, and avoid making fundamental changes to httpjson just for the Salesforce integration.

While we don't have a perfect approach to switching inputs in an existing integration, we do have some options which we can walk through. We are currently switching inputs on our Office 365 integration.

cc @SubhrataK

@narph
Copy link
Contributor

narph commented Aug 1, 2023

@kush-elastic , @SubhrataK , just a heads up here, we have planned efforts to improve and simplify the httpjson input #35432. After some discussion we've decided to hold off on the changes from this PR until the refactoring is complete and reassess the functionality after.

@mergify
Copy link
Contributor

mergify bot commented Sep 4, 2023

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 httjson-chaincall-fix upstream/httjson-chaincall-fix
git merge upstream/main
git push upstream httjson-chaincall-fix

1 similar comment
Copy link
Contributor

mergify bot commented Feb 5, 2024

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 httjson-chaincall-fix upstream/httjson-chaincall-fix
git merge upstream/main
git push upstream httjson-chaincall-fix

Copy link
Contributor

mergify bot commented Feb 5, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @kush-elastic? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@narph narph added Team:Security-Service Integrations Security Service Integrations Team and removed Team:Security-External Integrations labels Feb 8, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@ShourieG
Copy link
Contributor

Closing this issue as this was handled in the following meta issue : #35432

@ShourieG ShourieG closed this Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Team:Security-Service Integrations Security Service Integrations Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants