diff --git a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go index f1fb92d3a71..4d6a000408f 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go @@ -18,15 +18,21 @@ import ( const httpPlusPrefix = "http+" +var defaultMonitoringConfig = monitoringConfig.MonitoringConfig{ + Enabled: true, + MonitorLogs: true, + MonitorMetrics: true, +} + type wrappedConfig struct { - MonitoringConfig *monitoringConfig.MonitoringConfig `config:"settings.monitoring" yaml:"settings.monitoring"` + MonitoringConfig monitoringConfig.MonitoringConfig `config:"settings.monitoring" yaml:"settings.monitoring"` } // Monitor is a monitoring interface providing information about the way // how beat is monitored type Monitor struct { operatingSystem string - config *monitoringConfig.MonitoringConfig + config monitoringConfig.MonitoringConfig installPath string } @@ -35,21 +41,21 @@ func NewMonitor(downloadConfig *artifact.Config) *Monitor { return &Monitor{ operatingSystem: downloadConfig.OS(), installPath: downloadConfig.InstallPath, - config: &monitoringConfig.MonitoringConfig{}, + config: defaultMonitoringConfig, } } // Reload reloads state of the monitoring based on config. func (b *Monitor) Reload(rawConfig *config.Config) error { - cfg := &wrappedConfig{} + cfg := &wrappedConfig{ + MonitoringConfig: defaultMonitoringConfig, + } if err := rawConfig.Unpack(&cfg); err != nil { return err } - if cfg == nil || cfg.MonitoringConfig == nil { - b.config = &monitoringConfig.MonitoringConfig{} - } else { - b.config = cfg.MonitoringConfig + if cfg == nil { + b.config = defaultMonitoringConfig } return nil