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

Use server-side filtering when retrieving Cloud Foundry logs #33456

Merged
merged 11 commits into from
Nov 8, 2022

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Oct 25, 2022

What does this PR do?

Use server-side filtering when retrieving Cloud Foundry logs.

Why is it important?

It reduces CPU usage of Filebeat significatively.

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

  • Run Cloud Foundry input with firehose_filter: logs, check that log messages are still collected.

Related issues

Use cases

Screenshots

Logs

@jsoriano jsoriano requested a review from a team October 25, 2022 15:37
@jsoriano jsoriano self-assigned this Oct 25, 2022
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 25, 2022
@botelastic
Copy link

botelastic bot commented Oct 25, 2022

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

@mergify
Copy link
Contributor

mergify bot commented Oct 25, 2022

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @jsoriano? 🙏.
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 Oct 25, 2022

💚 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: 2022-11-08T09:02:23.793+0000

  • Duration: 74 min 45 sec

Test stats 🧪

Test Results
Failed 0
Passed 7058
Skipped 335
Total 7393

💚 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!)

@mergify
Copy link
Contributor

mergify bot commented Oct 27, 2022

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 cloudfoundry-config-filter upstream/cloudfoundry-config-filter
git merge upstream/main
git push upstream cloudfoundry-config-filter

@MichaelKatsoulis MichaelKatsoulis marked this pull request as ready for review November 7, 2022 10:26
@MichaelKatsoulis MichaelKatsoulis requested a review from a team as a code owner November 7, 2022 10:26
@MichaelKatsoulis MichaelKatsoulis requested review from fearful-symmetry and faec and removed request for a team November 7, 2022 10:26
@jsoriano
Copy link
Member Author

jsoriano commented Nov 7, 2022

/package

Copy link
Member Author

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

@MichaelKatsoulis @gizas if both logs modes collect the same logs, I wonder if we should just use the new method with server and client filtering, and don't expose the option to user. Wdyt?

Comment on lines 115 to 116
// TODO: Handle unknown filters.
return filterNoFilter, -1
Copy link
Member Author

Choose a reason for hiding this comment

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

We should decide if we want some kind of error handling here, or if we just consider all the default in this case.

return filterLogs, -1
case FirehoseFilterLogs:
// Uses filter-type=logs in requests to the firehose.
return filterLogs, consumer.LogMessages
Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM to use both filters here.

@@ -80,23 +81,49 @@ func (c *DopplerConsumer) Run() {
}

func (c *DopplerConsumer) logsFirehose() {
c.firehose(c.callbacks.Log, consumer.LogMessages)
filter := FirehoseFilterAllLogs
Copy link
Member Author

Choose a reason for hiding this comment

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

If we are sure that FirehoseFilterAllLogs and FirehoseFilterLogs collect the same logs, but FirehoseFilterLogs is much more efficient, wdyt about using FirehoseFilterLogs here and don't expose the option to the user?

Suggested change
filter := FirehoseFilterAllLogs
filter := FirehoseFilterLogs

@MichaelKatsoulis
Copy link
Contributor

@MichaelKatsoulis @gizas if both logs modes collect the same logs, I wonder if we should just use the new method with server and client filtering, and don't expose the option to user. Wdyt?

+1 on that. Let's not expose the logs vs all-logs. Let's keep all-logs with server and client side filtering , but expose the other options

@jsoriano
Copy link
Member Author

jsoriano commented Nov 7, 2022

Let's not expose the logs vs all-logs. Let's keep all-logs with server and client side filtering , but expose the other options

And given that, shall we be exposing anything at all regarding this?

I have pushed a couple of changes, to remove all-logs vs. logs and to completely remove the setting and simplify the code, let me know what you think.

@mergify
Copy link
Contributor

mergify bot commented Nov 8, 2022

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 cloudfoundry-config-filter upstream/cloudfoundry-config-filter
git merge upstream/main
git push upstream cloudfoundry-config-filter

@MichaelKatsoulis
Copy link
Contributor

And given that, shall we be exposing anything at all regarding this?

I agree. Let's keep it simpler. I will test it and then we can merge it

@MichaelKatsoulis
Copy link
Contributor

@jsoriano it works as expected. We can merge when ci passes

@jsoriano jsoriano changed the title Expose Cloud Foundry filtering into user configuration Use server-side filtering when retrieving Cloud Foundry logs Nov 8, 2022
@jsoriano jsoriano merged commit 5cd8b09 into elastic:main Nov 8, 2022
@jsoriano jsoriano deleted the cloudfoundry-config-filter branch November 8, 2022 11:01
@MichaelKatsoulis MichaelKatsoulis added the backport-7.17 Automated backport to the 7.17 branch with mergify label Nov 10, 2022
mergify bot pushed a commit that referenced this pull request Nov 10, 2022
It reduces CPU usage of Filebeat significatively.

Co-authored-by: MichaelKatsoulis <[email protected]>
(cherry picked from commit 5cd8b09)
MichaelKatsoulis added a commit that referenced this pull request Nov 10, 2022
…ud Foundry logs (#33637)

* Use server-side filtering when retrieving Cloud Foundry logs (#33456)

It reduces CPU usage of Filebeat significatively.

Co-authored-by: MichaelKatsoulis <[email protected]>
(cherry picked from commit 5cd8b09)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Jaime Soriano Pastor <[email protected]>
Co-authored-by: Michael Katsoulis <[email protected]>
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
It reduces CPU usage of Filebeat significatively.

Co-authored-by: MichaelKatsoulis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.17 Automated backport to the 7.17 branch with mergify needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants