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

Apply Autodiscovery dynamic fields in autoreloading #19135

Merged
merged 8 commits into from
Jun 15, 2020

Conversation

urso
Copy link

@urso urso commented Jun 11, 2020

  • Refactoring

What does this PR do?

Add a helper WithDynamicFields to pipetool 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

  • 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.

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 type common.MapStrPointer has been removed. The Processing.DynamicFields is not required to be set anymore when calling pipeline.ConnectWith.

Related issues

@urso urso requested a review from a team as a code owner June 11, 2020 18:44
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 11, 2020
@urso 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
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 11, 2020
@urso urso added the needs_backport PR is waiting to be backported to other branches. label Jun 11, 2020
@urso urso marked this pull request as draft June 11, 2020 18:46
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 11, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [urso commented: jenkins run the tests please]

  • Start Time: 2020-06-15T13:40:36.361+0000

  • Duration: 74 min 32 sec

Test stats 🧪

Test Results
Failed 0
Passed 9441
Skipped 1574
Total 11015

@urso urso force-pushed the with-dynamic-fields-helper branch from c836e6e to ba08e18 Compare June 12, 2020 15:16
@urso urso force-pushed the with-dynamic-fields-helper branch from ba08e18 to 1183ed8 Compare June 12, 2020 18:21
@urso urso marked this pull request as ready for review June 12, 2020 20:52
@urso urso added review and removed in progress Pull request is currently in progress. labels Jun 12, 2020
@andresrc andresrc added the Team:Integrations Label for the Integrations team label Jun 15, 2020
@urso
Copy link
Author

urso commented Jun 15, 2020

jenkins run the tests please

@urso urso changed the title With dynamic fields helper Apply Autodiscovery dynamic fields in autoreloading Jun 15, 2020
@urso
Copy link
Author

urso commented Jun 15, 2020

jenkins run the tests please

Copy link
Contributor

@exekias exekias left a 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

@exekias exekias added the test-plan Add this PR to be manual test plan label Jun 15, 2020
@urso urso merged commit e76e914 into elastic:master Jun 15, 2020
@urso urso deleted the with-dynamic-fields-helper branch June 15, 2020 15:21
@urso urso added the v7.9.0 label Jun 17, 2020
@urso urso removed the needs_backport PR is waiting to be backported to other branches. label Jul 7, 2020
urso pushed a commit to urso/beats that referenced this pull request Jul 7, 2020
urso pushed a commit that referenced this pull request Jul 7, 2020
@andresrc andresrc added the test-plan-added This PR has been added to the test plan label Jul 14, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants