Skip to content

Commit

Permalink
[elastic-agent] respect host configuration for http endpoint (#25114)
Browse files Browse the repository at this point in the history
When http processes endpoint is enabled, do not hardcode http endpoint
to localhost. This would not work for docker environments.
  • Loading branch information
simitt authored Apr 16, 2021
1 parent ae02c5f commit ff97e0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- Add support for filestream input. {pull}24820[24820]
- Add check for URL set when cert and cert key. {pull}24904[24904]
- Fix install command for Fleet Server bootstrap, remove need for --enrollment-token when using --fleet-server {pull}24981[24981]
- Respect host configuration for exposed processes endpoint {pull}25114[25114]

==== New features

Expand Down
4 changes: 2 additions & 2 deletions x-pack/elastic-agent/pkg/core/monitoring/beats/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
// args: pipeline name, application name
agentMbEndpointFileFormatWin = `npipe:///elastic-agent`
// agentMbEndpointHTTP is used with cloud and exposes metrics on http endpoint
agentMbEndpointHTTP = "http://localhost:%d"
agentMbEndpointHTTP = "http://%s:%d"
)

// MonitoringEndpoint is an endpoint where process is exposing its metrics.
Expand Down Expand Up @@ -60,7 +60,7 @@ func getLoggingFile(spec program.Spec, operatingSystem, installPath, pipelineID
// AgentMonitoringEndpoint returns endpoint with exposed metrics for agent.
func AgentMonitoringEndpoint(operatingSystem string, cfg *monitoringConfig.MonitoringHTTPConfig) string {
if cfg != nil && cfg.Enabled {
return fmt.Sprintf(agentMbEndpointHTTP, cfg.Port)
return fmt.Sprintf(agentMbEndpointHTTP, cfg.Host, cfg.Port)
}

if operatingSystem == "windows" {
Expand Down

0 comments on commit ff97e0e

Please sign in to comment.