From ea8dd1ba9c209e32645d6a125facd18085d76ced Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Tue, 5 May 2020 09:52:36 +0200 Subject: [PATCH 1/2] [Agent] Change monitoring defaults WIP --- .../core/plugin/app/monitoring/beats/beats_monitor.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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..586d87ffa9b 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,6 +18,12 @@ 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"` } @@ -35,7 +41,7 @@ func NewMonitor(downloadConfig *artifact.Config) *Monitor { return &Monitor{ operatingSystem: downloadConfig.OS(), installPath: downloadConfig.InstallPath, - config: &monitoringConfig.MonitoringConfig{}, + config: &defaultMonitoringConfig, } } @@ -47,7 +53,7 @@ func (b *Monitor) Reload(rawConfig *config.Config) error { } if cfg == nil || cfg.MonitoringConfig == nil { - b.config = &monitoringConfig.MonitoringConfig{} + b.config = &defaultMonitoringConfig } else { b.config = cfg.MonitoringConfig } From 35aa3756795d8b0e3b58df12917452c8178edd0f Mon Sep 17 00:00:00 2001 From: beats-jenkins Date: Tue, 5 May 2020 09:57:40 +0200 Subject: [PATCH 2/2] remove reference part --- .../plugin/app/monitoring/beats/beats_monitor.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 586d87ffa9b..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 @@ -25,14 +25,14 @@ var defaultMonitoringConfig = monitoringConfig.MonitoringConfig{ } 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 } @@ -41,21 +41,21 @@ func NewMonitor(downloadConfig *artifact.Config) *Monitor { return &Monitor{ operatingSystem: downloadConfig.OS(), installPath: downloadConfig.InstallPath, - config: &defaultMonitoringConfig, + 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 = &defaultMonitoringConfig - } else { - b.config = cfg.MonitoringConfig + if cfg == nil { + b.config = defaultMonitoringConfig } return nil