From 6fa4d6fa22db13e5187ad03d20cad83c93d946af Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 24 May 2021 15:02:23 -0700 Subject: [PATCH] [Fleet] Pass policy namespace to agent monitoring settings (#100500) * Pass agent policy namespace to agent monitoring settings * Adjust copy --- x-pack/plugins/fleet/common/types/models/agent_policy.ts | 1 + .../sections/agent_policy/components/agent_policy_form.tsx | 2 +- x-pack/plugins/fleet/server/services/agent_policy.test.ts | 4 ++++ x-pack/plugins/fleet/server/services/agent_policy.ts | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/common/types/models/agent_policy.ts b/x-pack/plugins/fleet/common/types/models/agent_policy.ts index a8e1f6ce584d4ac..753100f62255677 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -91,6 +91,7 @@ export interface FullAgentPolicy { revision?: number; agent?: { monitoring: { + namespace?: string; use_output?: string; enabled: boolean; metrics: boolean; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx index 7bfb2961a6d65ef..a44edb5ce9a422f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx @@ -223,7 +223,7 @@ export const AgentPolicyForm: React.FunctionComponent = ({ description={ } > diff --git a/x-pack/plugins/fleet/server/services/agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policy.test.ts index 68bd9e721d714b9..a020b95ca3302b1 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.test.ts @@ -185,6 +185,7 @@ describe('agent policy', () => { it('should return a policy with monitoring if monitoring is enabled for logs', async () => { const soClient = getSavedObjectMock({ + namespace: 'default', revision: 1, monitoring_enabled: ['logs'], }); @@ -207,6 +208,7 @@ describe('agent policy', () => { }, agent: { monitoring: { + namespace: 'default', use_output: 'default', enabled: true, logs: true, @@ -218,6 +220,7 @@ describe('agent policy', () => { it('should return a policy with monitoring if monitoring is enabled for metrics', async () => { const soClient = getSavedObjectMock({ + namespace: 'default', revision: 1, monitoring_enabled: ['metrics'], }); @@ -240,6 +243,7 @@ describe('agent policy', () => { }, agent: { monitoring: { + namespace: 'default', use_output: 'default', enabled: true, logs: false, diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index b575c1de1616d24..62b4578ab87b22c 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -730,6 +730,7 @@ class AgentPolicyService { ? { agent: { monitoring: { + namespace: agentPolicy.namespace, use_output: defaultOutput.name, enabled: true, logs: agentPolicy.monitoring_enabled.includes(dataTypes.Logs),