From b9754807f5fc03c088066b4c71d6e2f3d21c8441 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 8 Jun 2021 20:30:42 -0400 Subject: [PATCH] [APM] Improvments in the APM fleet integration (#95501) --- .../lib/fleet/register_fleet_policy_callbacks.ts | 1 + .../services/package_policies_to_agent_inputs.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts index e4306b4c2ec98..35c7f0dfdfd73 100644 --- a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts +++ b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts @@ -115,6 +115,7 @@ export function getPackagePolicyWithAgentConfigurations( { ...firstInput, config: { + ...firstInput.config, [APM_SERVER]: { value: { ...apmServerValue, diff --git a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts index 61d7764a832b1..8e6e7dd433823 100644 --- a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts +++ b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts @@ -7,6 +7,7 @@ import type { PackagePolicy, FullAgentPolicyInput, FullAgentPolicyInputStream } from '../types'; import { DEFAULT_OUTPUT } from '../constants'; +import { merge } from 'lodash'; export const storedPackagePoliciesToAgentInputs = ( packagePolicies: PackagePolicy[] @@ -31,10 +32,6 @@ export const storedPackagePoliciesToAgentInputs = ( namespace: packagePolicy.namespace || 'default', }, use_output: DEFAULT_OUTPUT.name, - ...Object.entries(input.config || {}).reduce((acc, [key, { value }]) => { - acc[key] = value; - return acc; - }, {} as { [k: string]: any }), ...(input.compiled_input || {}), ...(input.streams.length ? { @@ -56,6 +53,14 @@ export const storedPackagePoliciesToAgentInputs = ( : {}), }; + merge( + fullInput, + Object.entries(input.config || {}).reduce( + (acc, [key, { value }]) => ({ ...acc, [key]: value }), + {} + ) + ); + if (packagePolicy.package) { fullInput.meta = { package: {