Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/agent/pkg/agent/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func createApplication(
switch mgmt.Mode {
case localMode:
log.Info("Agent is managed locally")
return newLocal(log, pathConfigFile, c.Management)
return newLocal(log, pathConfigFile, config)
case fleetMode:
log.Info("Agent is managed by Fleet")
return newManaged(log, config)
Expand Down
24 changes: 15 additions & 9 deletions x-pack/agent/pkg/agent/application/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ func defaultManagementConfig() *ManagementConfig {
}

type localConfig struct {
Reload *reloadConfig `config:"reload"`
Path string `config:"path"`
Reporting *logreporter.Config `config:"reporting"`
Management *localManagementConfig `config:"management" yaml:"management"`
}

type localManagementConfig struct {
Reload *reloadConfig `config:"reload" yaml:"reload"`
Path string `config:"path" yaml:"path"`
Reporting *logreporter.Config `config:"reporting" yaml:"reporting"`
}

type reloadConfig struct {
Enabled bool `config:"enabled"`
Period time.Duration `config:"period"`
Enabled bool `config:"enabled" yaml:"enabled"`
Period time.Duration `config:"period" yaml:"period"`
}

func (r *reloadConfig) Validate() error {
Expand All @@ -89,11 +93,13 @@ func (r *reloadConfig) Validate() error {

func localConfigDefault() *localConfig {
return &localConfig{
Reload: &reloadConfig{
Enabled: true,
Period: 10 * time.Second,
Management: &localManagementConfig{
Reload: &reloadConfig{
Enabled: true,
Period: 10 * time.Second,
},
Reporting: logreporter.DefaultLogConfig(),
},
Reporting: logreporter.DefaultLogConfig(),
}
}

Expand Down
10 changes: 5 additions & 5 deletions x-pack/agent/pkg/agent/application/local_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func newLocal(
return nil, errors.Wrap(err, "initialize local mode")
}

logR := logreporter.NewReporter(log, c.Reporting)
logR := logreporter.NewReporter(log, c.Management.Reporting)

localApplication := &Local{
log: log,
Expand All @@ -78,16 +78,16 @@ func newLocal(
return nil, errors.Wrap(err, "fail to initialize pipeline router")
}

discover := discoverer(pathConfigFile, c.Path)
discover := discoverer(pathConfigFile, c.Management.Path)
emit := emitter(log, router, injectMonitoring)

var cfgSource source
if !c.Reload.Enabled {
if !c.Management.Reload.Enabled {
log.Debug("Reloading of configuration is off")
cfgSource = newOnce(log, discover, emit)
} else {
log.Debugf("Reloading of configuration is on, frequency is set to %s", c.Reload.Period)
cfgSource = newPeriodic(log, c.Reload.Period, discover, emit)
log.Debugf("Reloading of configuration is on, frequency is set to %s", c.Management.Reload.Period)
cfgSource = newPeriodic(log, c.Management.Reload.Period, discover, emit)
}

localApplication.source = cfgSource
Expand Down