-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Apply Autodiscovery dynamic fields in autoreloading #19135
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
botelastic
bot
added
the
needs_team
Indicates that the issue/PR needs a Team:* label
label
Jun 11, 2020
urso
added
Filebeat
Filebeat
Heartbeat
in progress
Pull request is currently in progress.
libbeat
Metricbeat
Metricbeat
Project:Filebeat-Input-v2
Team:Services
(Deprecated) Label for the former Integrations-Services team
labels
Jun 11, 2020
Pinging @elastic/integrations-services (Team:Services) |
botelastic
bot
removed
the
needs_team
Indicates that the issue/PR needs a Team:* label
label
Jun 11, 2020
urso
force-pushed
the
with-dynamic-fields-helper
branch
from
June 12, 2020 15:16
c836e6e
to
ba08e18
Compare
Add unit test to cfgfile package to test the dynamicFields are still applied when a new runner is created.
urso
force-pushed
the
with-dynamic-fields-helper
branch
from
June 12, 2020 18:21
ba08e18
to
1183ed8
Compare
urso
added
review
and removed
in progress
Pull request is currently in progress.
labels
Jun 12, 2020
jenkins run the tests please |
urso
changed the title
With dynamic fields helper
Apply Autodiscovery dynamic fields in autoreloading
Jun 15, 2020
jenkins run the tests please |
exekias
approved these changes
Jun 15, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good to me, thank you, much nicer now! In order to test this I think we could:
- Spin a kubernetes pod and a filebeat autodiscover config to read it's logs
- Update container metadata (ie add a label)
- Check that thew new events contain the new metadata
4 tasks
urso
pushed a commit
to urso/beats
that referenced
this pull request
Jul 7, 2020
(cherry picked from commit e76e914)
urso
pushed a commit
that referenced
this pull request
Jul 7, 2020
melchiormoulin
pushed a commit
to melchiormoulin/beats
that referenced
this pull request
Oct 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Filebeat
Filebeat
Heartbeat
libbeat
Metricbeat
Metricbeat
Project:Filebeat-Input-v2
review
Team:Integrations
Label for the Integrations team
Team:Services
(Deprecated) Label for the former Integrations-Services team
test-plan
Add this PR to be manual test plan
test-plan-added
This PR has been added to the test plan
v7.9.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Add a helper
WithDynamicFields
topipetool
package to configure dynamic fields added by Autodiscovery in a more consistent manner.Instead of the Beats having to add dynamic fields, the addition will be handled in libbeat only now.
In order to ease testing without the full beats publishing pipeline a FakeConnector and FakeClient have been added to
libbeat/pipeline/testing
Remove the configuration of dynamic fields from each filebeat input.
Why is it important?
Dynamic fields is a feature that was introduced to beats by autodiscovery. Instead of configuring fields a pointer to the fields to be added is shared. The autodiscovery provider can update the pointer to a new MapStr in order to reconfigure the fields without having to restart the input/module.
Currently each input needs to apply DynamicFields when connecting to the publisher pipeline. In Filebeat each Input has to add the fields when connecting, while Metricbeat and Heartbeat use custom wrappers.
With this change dynamic fields from autodiscovery are handled by libbeat in one single place only. This reduces duplication and sharing of responsibilities regarding autodiscovery specific code among the beats code base.
Note: responsibility for applying dynamic fields is still shared between autodiscovery and the cfgfile package. As the future of both package is somewhat in the flux I will not continue refactoring these two package for now (unless changes are required for the v2 input API).
This change is introduced to prepare for the input v2 API introduction in Beats. Moving common functionality up into more appropriate layers removes the need to reimplement the functionality in the new API.
Note: I didn't check in detail, but it looks like this changes fixes a bug in heartbeat not picking up dynamic field changes triggered by kuberenetes events.
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
The change should not be user visible. But in order to verify no regression is introduced some simple tests with kubernetes autodiscovery would be helpful (@exekias can you give details/instructions?)
Developer Docs
The
cfgfile.RunnerFactory
interface has been modified. The interface is used to integrate with AutoDiscovery or input configuration reloading. The last parameter of typecommon.MapStrPointer
has been removed. TheProcessing.DynamicFields
is not required to be set anymore when callingpipeline.ConnectWith
.Related issues