From b692f84481bee6f187bc6b3f394f0582cd64e4e5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 22:34:08 -0500 Subject: [PATCH] Fix APM server not being available in cloud. (#1781) (#1782) (cherry picked from commit b4002e9581f55e723c88761e872ae2e78d524959) Co-authored-by: Craig MacKenzie --- .../agent/application/monitoring/processes.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/pkg/agent/application/monitoring/processes.go b/internal/pkg/agent/application/monitoring/processes.go index 9649778fa51..95441fd9e06 100644 --- a/internal/pkg/agent/application/monitoring/processes.go +++ b/internal/pkg/agent/application/monitoring/processes.go @@ -50,9 +50,20 @@ func processesHandler(coord *coordinator.Coordinator) func(http.ResponseWriter, for _, c := range state.Components { if c.Component.InputSpec != nil { - procs = append(procs, process{c.Component.ID, c.Component.InputSpec.BinaryName, - c.LegacyPID, - sourceFromComponentID(c.Component.ID)}) + displayID := c.Component.ID + if strings.Contains(c.Component.InputSpec.BinaryName, "apm-server") { + // Cloud explicitly looks for an ID of "apm-server" to determine if APM is in managed mode. + // Ensure that this is the ID we use, at the time of writing it is "apm-default". + // Otherwise apm-server won't be routable/accessible in cloud. + // https://github.com/elastic/elastic-agent/issues/1731#issuecomment-1325862913 + displayID = "apm-server" + } + procs = append(procs, process{ + ID: displayID, + PID: c.LegacyPID, + Binary: c.Component.InputSpec.BinaryName, + Source: sourceFromComponentID(c.Component.ID), + }) } } data := struct {