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

Inject Beat specific default processors #34149

Merged
merged 4 commits into from
Dec 30, 2022

Conversation

michalpristas
Copy link
Contributor

What does this PR do?

Managed beats do not respect default processors configured in {beat}.yml file.
This results in events without host, k8s or docker metadata.

In this PR we take default processors from config file to callback responsible for handling configuration passed from agent and make sure they are included during generate step.

Why is it important?

Missing metadata may break dashboards

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.

Fixes: #34125

@michalpristas michalpristas added Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-v8.6.0 Automated backport with mergify labels Dec 30, 2022
@michalpristas michalpristas self-assigned this Dec 30, 2022
@michalpristas michalpristas requested review from a team as code owners December 30, 2022 10:26
@michalpristas michalpristas requested review from cmacknz and removed request for a team December 30, 2022 10:26
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 30, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 30, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 30, 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-12-30T16:05:51.205+0000

  • Duration: 85 min 38 sec

Test stats 🧪

Test Results
Failed 0
Passed 7408
Skipped 338
Total 7746

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

@michalpristas
Copy link
Contributor Author

michalpristas commented Dec 30, 2022

Reordered processors so default are first,
image

image

image

@@ -94,7 +94,7 @@ func CreateInputsFromStreams(raw *proto.UnitExpectedConfig, inputType string, ag
}

// 3. stream processors
streamSource, err = injectStreamProcessors(raw, inputType, stream, streamSource)
streamSource, err = injectStreamProcessors(raw, inputType, stream, streamSource, defaultProcessors)
Copy link
Member

Choose a reason for hiding this comment

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

There is this above:

		// 1. global processors
		streamSource = injectGlobalProcesssors(raw, streamSource)

The metadata processors behave more like global processors don't they? Shouldn't they be added there?

Both prepend and append are used here to control the order so just reading this code it is a bit tricky to follow what ends up where.

Could you post an example beat-rendered-config if you have one from diagnostics with this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but if you check the final order of the processors it's

		// now the order of the processors on this input is as follows
		// 1. stream processors
		// 2. agentInfo processors
		// 3. global processors
		// 4. stream specific processors

so if we put it with global, they will be pushed to later stage by next 2 steps. this is why i went with stream

  • it makes sure it's first
  • it makes clear that it will be part of the stream

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

@@ -1,11 +0,0 @@
# Module: enterprisesearch
Copy link
Member

Choose a reason for hiding this comment

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

This file was committed by mistake I think, I see this come in when changing branches occasionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep probably changing branches

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

Thanks!

@michalpristas michalpristas merged commit 75ebd50 into elastic:main Dec 30, 2022
mergify bot pushed a commit that referenced this pull request Dec 30, 2022
Inject Beat specific default processors (#34149)

(cherry picked from commit 75ebd50)
michalpristas added a commit that referenced this pull request Dec 30, 2022
Inject Beat specific default processors (#34149)

(cherry picked from commit 75ebd50)

Co-authored-by: Michal Pristas <[email protected]>
@fearful-symmetry
Copy link
Contributor

Just a heads up, I'm running into some weird behaviors with the processors under elastic-agent. They seem to be putting the beat in some kind of wedged state where elastic-agent won't actually stop when it gets a sigint. I can't manually remove the processors either, but commenting out the defaultProcessors line seems to fix it. Will investigate more tomorrow.

@cmacknz
Copy link
Member

cmacknz commented Jan 12, 2023

Thanks. FYI the default processors aren't new, they would have been configured in a different way prior to 8.6 (reading the default beat config file at startup) but they would have been running regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.6.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet]: Host Details are not available under predefined filters in the Search bar of Agents Logs tab.
4 participants