Apply Autodiscovery dynamic fields in autoreloading#19135
Merged
urso merged 8 commits intoelastic:masterfrom Jun 15, 2020
Merged
Apply Autodiscovery dynamic fields in autoreloading#19135urso merged 8 commits intoelastic:masterfrom
urso merged 8 commits intoelastic:masterfrom
Conversation
Contributor
|
Pinging @elastic/integrations-services (Team:Services) |
Contributor
c836e6e to
ba08e18
Compare
added 6 commits
June 12, 2020 20:21
Add unit test to cfgfile package to test the dynamicFields are still applied when a new runner is created.
ba08e18 to
1183ed8
Compare
Author
|
jenkins run the tests please |
Author
|
jenkins run the tests please |
exekias
approved these changes
Jun 15, 2020
Contributor
exekias
left a comment
There was a problem hiding this comment.
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
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
WithDynamicFieldstopipetoolpackage 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/testingRemove 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.asciidocorCHANGELOG-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.RunnerFactoryinterface has been modified. The interface is used to integrate with AutoDiscovery or input configuration reloading. The last parameter of typecommon.MapStrPointerhas been removed. TheProcessing.DynamicFieldsis not required to be set anymore when callingpipeline.ConnectWith.Related issues