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

Refactor autodiscover to make it reusable in the Agent #19271

Closed
exekias opened this issue Jun 18, 2020 · 6 comments · Fixed by #21480
Closed

Refactor autodiscover to make it reusable in the Agent #19271

exekias opened this issue Jun 18, 2020 · 6 comments · Fixed by #21480
Assignees
Labels
Agent autodiscovery discuss Issue needs further discussion. enhancement ext-goal External goal of an iteration Team:Platforms Label for the Integrations - Platforms team

Comments

@exekias
Copy link
Contributor

exekias commented Jun 18, 2020

Describe the enhancement:

We want to support autodiscover features in the Agent (#19225). For this, it would be nice if we could reuse the existing providers and make Agent handle the runner start/stop logic.

Current status

Right now, autodiscover providers send start/stop events through a bus. The autodiscover manager listens into this bus and manages input/module runners according to these events.

Providers are coupled to config generation (through templates or hints), although all this code is contained in libraries. It is used like this:

// Try to match a config
if config := d.templates.GetConfig(event); config != nil {
event["config"] = config
} else {
// If no template matches, try builders:
if config := d.builders.GetConfig(d.generateHints(event)); config != nil {
event["config"] = config
}
}

I don't see any reason why cannot be done by autodiscover manager (and not the providers) ^

Proposal

To make providers reusable, we need to decouple them from the config generation / runner handling, a few things we would need to do:

  • Refactor autodiscover to move the template logic away from providers, into the autodiscover manager.
  • Re-define the schema for autodiscover events. For instance, we should include hints into them (instead of the generated config). It should be serializable (cannot carry things like a keystore or meta pointer)

Some caveats:

  • We are currently using dynamic fields (a pointer we can update in memory) to update metadata without restarting runners, we may need to rethink this?
  • Kubernetes autodiscover supports keystore (again, at the provider level), should this be moved into the autodiscover manager? We can leave it out of Agent for now.

Agent will implement a new template logic that can be hooked into provider events (see the parent issue for more details).

@exekias exekias added enhancement discuss Issue needs further discussion. autodiscovery Team:Platforms Label for the Integrations - Platforms team Agent labels Jun 18, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@exekias
Copy link
Contributor Author

exekias commented Jun 18, 2020

@jsoriano @ChrsMark would love your thoughts on this one

@ChrsMark
Copy link
Member

ChrsMark commented Jun 26, 2020

  • Kubernetes autodiscover supports keystore (again, at the provider level), should this be moved into the autodiscover manager? We can leave it out of Agent for now.

Note that there are 2 Keystore types, file based one (or local) and k8s' Secret based one.
The local one is available in Autodiscover Manager, the other one is coupled with the Kubernetes Provider and it's not available in Autodiscover Manager. Speaking of this I wonder what would be the relationship of Manager-Provider with the new approach.

@jsoriano
Copy link
Member

The plan sounds good to me, any common logic that we can move out from the providers sounds great.

@exekias
Copy link
Contributor Author

exekias commented Jul 14, 2020

The local one is available in Autodiscover Manager, the other one is coupled with the Kubernetes Provider and it's not available in Autodiscover Manager. Speaking of this I wonder what would be the relationship of Manager-Provider with the new approach.

It would be through the autodiscover events only. The providers will send start/stop events, but won't really know about the templates or what inputs get started.

I understand static secrets (the ones in templates) must be handled by the manager, but we will need to figure out how we make k8s secrets work when coming from hints.

@exekias
Copy link
Contributor Author

exekias commented Oct 6, 2020

I have implemented a Pod discovery provider here #21480, we are finally not reusing the whole autodiscover providers for this, but implementing things based on the common watcher code.

I expect more conversations to happen around the missing pieces, will open issues for them:

  • Discovery of other resources (Node, service)
  • Kubernetes secrets
  • Hints based autodiscover
  • Hopefully improve the logic for delayed stop of Filebeat inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent autodiscovery discuss Issue needs further discussion. enhancement ext-goal External goal of an iteration Team:Platforms Label for the Integrations - Platforms team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants