diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index aa84ada1acf..45ddd69a275 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -22,6 +22,7 @@ - Fix issues when running `mage package` for all the platforms. {pull}17767[17767] - Remove the kbn-version on each request to the Kibana API. {pull}17764[17764] - Fixed process spawning on Windows {pull}17751[17751] +- Fixed injected log path to monitoring beat {pull}17833[17833] ==== New features diff --git a/x-pack/elastic-agent/_meta/common.p2.yml b/x-pack/elastic-agent/_meta/common.p2.yml index 0ff0776250e..651f02282dd 100644 --- a/x-pack/elastic-agent/_meta/common.p2.yml +++ b/x-pack/elastic-agent/_meta/common.p2.yml @@ -112,7 +112,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/_meta/common.reference.p2.yml b/x-pack/elastic-agent/_meta/common.reference.p2.yml index b27d681bfb9..eaa97536e0b 100644 --- a/x-pack/elastic-agent/_meta/common.reference.p2.yml +++ b/x-pack/elastic-agent/_meta/common.reference.p2.yml @@ -112,7 +112,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/_meta/elastic-agent.docker.yml b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml index 07dec01f4a1..dbf7931b690 100644 --- a/x-pack/elastic-agent/_meta/elastic-agent.docker.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml @@ -86,7 +86,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/_meta/elastic-agent.yml b/x-pack/elastic-agent/_meta/elastic-agent.yml index e0f7acc636d..12fbfabc3fe 100644 --- a/x-pack/elastic-agent/_meta/elastic-agent.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.yml @@ -87,7 +87,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/elastic-agent.docker.yml b/x-pack/elastic-agent/elastic-agent.docker.yml index 07dec01f4a1..dbf7931b690 100644 --- a/x-pack/elastic-agent/elastic-agent.docker.yml +++ b/x-pack/elastic-agent/elastic-agent.docker.yml @@ -86,7 +86,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/elastic-agent.reference.yml b/x-pack/elastic-agent/elastic-agent.reference.yml index 7b1ee5cca98..2fb40550bc7 100644 --- a/x-pack/elastic-agent/elastic-agent.reference.yml +++ b/x-pack/elastic-agent/elastic-agent.reference.yml @@ -117,7 +117,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/elastic-agent.yml b/x-pack/elastic-agent/elastic-agent.yml index a5fd150155b..24331ef7f9f 100644 --- a/x-pack/elastic-agent/elastic-agent.yml +++ b/x-pack/elastic-agent/elastic-agent.yml @@ -117,7 +117,7 @@ retry: # Default is false exponential: false -monitoring: +settings.monitoring: # enabled turns on monitoring of running processes enabled: false # enables log monitoring diff --git a/x-pack/elastic-agent/pkg/agent/operation/monitoring.go b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go index 8157bf9e876..85b6bb2a865 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/monitoring.go +++ b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go @@ -225,6 +225,8 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i }, } + o.logger.Debugf("monitoring configuration generated for filebeat: %v", result) + return result, true } @@ -250,6 +252,8 @@ func (o *Operator) getMonitoringMetricbeatConfig(output interface{}) (map[string }, } + o.logger.Debugf("monitoring configuration generated for metricbeat: %v", result) + return result, true } 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 eda80bf1ffe..8c245960a0a 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 @@ -24,6 +24,7 @@ type Monitor struct { process string monitoringEndpoint string loggingPath string + loggingFile string monitorLogs bool monitorMetrics bool @@ -31,13 +32,15 @@ type Monitor struct { // NewMonitor creates a beats monitor. func NewMonitor(process, pipelineID string, downloadConfig *artifact.Config, monitorLogs, monitorMetrics bool) *Monitor { - var monitoringEndpoint, loggingPath string + var monitoringEndpoint, loggingPath, loggingFile string if monitorMetrics { monitoringEndpoint = getMonitoringEndpoint(process, downloadConfig.OS(), pipelineID) } if monitorLogs { - loggingPath = getLoggingFileDirectory(downloadConfig.InstallPath, downloadConfig.OS(), pipelineID) + operatingSystem := downloadConfig.OS() + loggingFile = getLoggingFile(process, operatingSystem, downloadConfig.InstallPath, pipelineID) + loggingPath = filepath.Dir(loggingFile) } return &Monitor{ @@ -45,6 +48,7 @@ func NewMonitor(process, pipelineID string, downloadConfig *artifact.Config, mon process: process, monitoringEndpoint: monitoringEndpoint, loggingPath: loggingPath, + loggingFile: loggingFile, monitorLogs: monitorLogs, monitorMetrics: monitorMetrics, } @@ -125,7 +129,7 @@ func (b *Monitor) LogPath() string { return "" } - return b.loggingPath + return b.loggingFile } // MetricsPath describes a location where application exposes metrics diff --git a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go index a69581b3ff9..c551f5ef18c 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go @@ -6,7 +6,6 @@ package beats import ( "fmt" - "path/filepath" ) const ( @@ -36,7 +35,3 @@ func getLoggingFile(program, operatingSystem, installPath, pipelineID string) st return fmt.Sprintf(logFileFormat, pipelineID, program) } - -func getLoggingFileDirectory(installPath, operatingSystem, pipelineID string) string { - return filepath.Base(getLoggingFile("program", operatingSystem, installPath, pipelineID)) -}