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

Beats run under agent should start without reading a configuration file from disk. #31901

Closed
Tracked by #32
cmacknz opened this issue Jun 9, 2022 · 5 comments
Closed
Tracked by #32
Assignees
Labels
Agent Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.4.0

Comments

@cmacknz
Copy link
Member

cmacknz commented Jun 9, 2022

For compatibility with the V2 agent control protocol, beats run under agent should start without loading a configuration file from disk. Preferably a beat run under agent should start, establish a V2 control protocol client, and wait for an initial configuration from the agent.

This issue is cloned from @michalpristas's original comment in the V1 protocol removal issue: elastic/elastic-agent-client#32 (comment)

Beats behaviour change

Current

At the moment we handle process as this:

  • elastic agent starts
  • elastic agent is notified about or detects config change
  • elastic agent creates a specific change for specific beats (let's assume filebeat from now on)
  • elastic agent starts filebeat process with -management.enabled flag
  • filebeat process starts
  • filebeat loads a config from filebeat.yml
	cfg, err := cfgfile.Load("", settings.ConfigOverrides)
	if err != nil {
		return fmt.Errorf("error loading config file: %w", err)
	}
  • filebeat initializes manager to get comms with agent going
	// initialize config manager
	b.Manager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
	if err != nil {
		return err
	}
  • filebeat fetches config from fleet

Proposed

  • elastic agent starts
  • elastic agent is notified about or detects config change
  • elastic agent creates a specific change for specific beats (let's assume filebeat from now on)
  • elastic agent starts filebeat process with -management.enabled flag
  • filebeat process starts
  • in case management.enabled flag is not set filebeat loads a config from filebeat.yml otherwise use sane default configuration
	cfg, err := cfgfile.Load("", settings.ConfigOverrides)
	if err != nil {
		return fmt.Errorf("error loading config file: %w", err)
	}
  • filebeat initializes manager to get comms with agent going
	// initialize config manager
	b.Manager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
	if err != nil {
		return err
	}
  • filebeat fetches config from fleet2
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 9, 2022
@cmacknz cmacknz added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jun 9, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 9, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@cmacknz
Copy link
Member Author

cmacknz commented Jun 15, 2022

Switching the assigning to @fearful-symmetry here as they are likely free next, and this will line up more closely with the input V2 work than the shipper work.

@cmacknz cmacknz assigned fearful-symmetry and unassigned rdner Jun 15, 2022
@cmacknz
Copy link
Member Author

cmacknz commented Jun 21, 2022

There is a chance this overlaps with the work needed for #31900, ideally they can be done independently but we'll need to sync up first.

@simitt
Copy link
Contributor

simitt commented Aug 24, 2022

Is this going to be handled purely in libbeat or do users of libbeat need to adapt their logic?

APM Server is currently making use of cfgfile.ConditionalOverride in two places (e.g. https://github.com/elastic/apm-server/blob/main/internal/beatcmd/root.go#L42-L68) - will this still be supported (also for fleet managed mode)?

cc @axw

@cmacknz
Copy link
Member Author

cmacknz commented Aug 24, 2022

It should be handled in libbeat, see the change to libbeat/cfgfile/cfgfile.go in #32673.

Essentially instead of reading the configuration from disk it just constructs a default configuration in place with config.NewConfig() before applying any overrides. I'll make a note on the PR to confirm, but I believe the overrides should still apply

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

No branches or pull requests

6 participants