Skip to content

Commit

Permalink
[Agent] Fixed injected log path to monitoring beat (#17833)
Browse files Browse the repository at this point in the history
[Agent] Fixed injected log path to monitoring beat  (#17833)
  • Loading branch information
michalpristas authored Apr 20, 2020
1 parent afc3a49 commit a16a2a3
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/_meta/common.p2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/_meta/common.reference.p2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/_meta/elastic-agent.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/_meta/elastic-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/elastic-agent.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/elastic-agent.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/elastic-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,31 @@ type Monitor struct {
process string
monitoringEndpoint string
loggingPath string
loggingFile string

monitorLogs bool
monitorMetrics bool
}

// 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{
pipelineID: pipelineID,
process: process,
monitoringEndpoint: monitoringEndpoint,
loggingPath: loggingPath,
loggingFile: loggingFile,
monitorLogs: monitorLogs,
monitorMetrics: monitorMetrics,
}
Expand Down Expand Up @@ -125,7 +129,7 @@ func (b *Monitor) LogPath() string {
return ""
}

return b.loggingPath
return b.loggingFile
}

// MetricsPath describes a location where application exposes metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package beats

import (
"fmt"
"path/filepath"
)

const (
Expand Down Expand Up @@ -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))
}

0 comments on commit a16a2a3

Please sign in to comment.