From 54f48e6e4356765cdb6ef3b9b92276719c5d0ac9 Mon Sep 17 00:00:00 2001 From: criamico Date: Wed, 10 Apr 2024 17:03:26 +0200 Subject: [PATCH 1/9] [Fleet] Expose agent logging level in agent policy settings --- .../fleet/common/constants/agent_policy.ts | 7 +++ .../fleet/common/types/models/agent_policy.ts | 4 +- .../agent_policy_advanced_fields/index.tsx | 47 ++++++++++++++++++- .../fleet/server/saved_objects/index.ts | 1 + .../fleet/server/types/models/agent_policy.ts | 12 ++++- 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/fleet/common/constants/agent_policy.ts b/x-pack/plugins/fleet/common/constants/agent_policy.ts index a52a0cdc7bfcb..4a8a9fc1c6927 100644 --- a/x-pack/plugins/fleet/common/constants/agent_policy.ts +++ b/x-pack/plugins/fleet/common/constants/agent_policy.ts @@ -37,3 +37,10 @@ export const LICENSE_FOR_SCHEDULE_UPGRADE = 'platinum'; export const DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT = 750; export const AGENTLESS_POLICY_ID = 'agentless'; // the policy id defined here: https://github.com/elastic/project-controller/blob/main/internal/project/security/security_kibana_config.go#L86 + +export const agentLoggingLevels = { + Info: 'info', + Debug: 'debug', + Warning: 'warning', + Error: 'error', +} as const; 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 60e635f73f6cc..96ef8b249078e 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -7,13 +7,14 @@ import type { SecurityRoleDescriptor } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { agentPolicyStatuses } from '../../constants'; +import type { agentPolicyStatuses, agentLoggingLevels } from '../../constants'; import type { MonitoringType, PolicySecretReference, ValueOf } from '..'; import type { PackagePolicy, PackagePolicyPackage } from './package_policy'; import type { Output } from './output'; export type AgentPolicyStatus = typeof agentPolicyStatuses; +export type AgentLoggingLevels = typeof agentLoggingLevels; // adding a property here? If it should be cloned when duplicating a policy, add it to `agentPolicyService.copy` // x-pack/plugins/fleet/server/services/agent_policy.ts#L571 @@ -40,6 +41,7 @@ export interface NewAgentPolicy { is_protected?: boolean; overrides?: { [key: string]: any } | null; advanced_settings?: { [key: string]: any } | null; + logging_level?: ValueOf; } // SO definition for this type is declared in server/types/interfaces diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index 02795f8005bf5..c18d8a19f4190 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -25,6 +25,7 @@ import { EuiBetaBadge, EuiBadge, EuiSwitch, + EuiSelect, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; @@ -33,6 +34,7 @@ import { AGENT_POLICY_SAVED_OBJECT_TYPE, dataTypes, DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT, + agentLoggingLevels, } from '../../../../../../../common/constants'; import type { NewAgentPolicy, AgentPolicy } from '../../../../types'; import { @@ -74,6 +76,8 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = isEditing = false, disabled = false, }) => { + const LEVEL_VALUES = Object.keys(agentLoggingLevels); + const { docLinks } = useStartServices(); const AgentTamperProtectionWrapper = useUIExtension( 'endpoint', @@ -401,7 +405,48 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = }} /> - + + + + } + description={ + + } + > + + { + updateAgentPolicy({ + logging_level: e.target.value, + }); + }} + options={LEVEL_VALUES.map((level) => ({ + text: level, + value: agentLoggingLevels[level], + }))} + /> + + {AgentTamperProtectionSection} ({ overrides: { type: 'flattened', index: false }, keep_monitoring_alive: { type: 'boolean' }, advanced_settings: { type: 'flattened', index: false }, + logging_level: { type: 'keyword', index: false }, }, }, migrations: { diff --git a/x-pack/plugins/fleet/server/types/models/agent_policy.ts b/x-pack/plugins/fleet/server/types/models/agent_policy.ts index 748a5c81c1bfb..054c4b90dd402 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -7,7 +7,7 @@ import { schema } from '@kbn/config-schema'; -import { agentPolicyStatuses, dataTypes } from '../../../common/constants'; +import { agentPolicyStatuses, dataTypes, agentLoggingLevels } from '../../../common/constants'; import { isValidNamespace } from '../../../common/services'; import { getSettingsAPISchema } from '../../services/form_settings'; @@ -62,6 +62,16 @@ export const AgentPolicyBaseSchema = { monitoring_output_id: schema.maybe(schema.nullable(schema.string())), download_source_id: schema.maybe(schema.nullable(schema.string())), fleet_server_host_id: schema.maybe(schema.nullable(schema.string())), + logging_level: schema.maybe( + schema.nullable( + schema.oneOf([ + schema.literal(agentLoggingLevels.Info), + schema.literal(agentLoggingLevels.Debug), + schema.literal(agentLoggingLevels.Warning), + schema.literal(agentLoggingLevels.Error), + ]) + ) + ), agent_features: schema.maybe( schema.arrayOf( schema.object({ From 88fd21f22a9a833dab24be87a3b2808d8be30815 Mon Sep 17 00:00:00 2001 From: criamico Date: Thu, 11 Apr 2024 12:35:55 +0200 Subject: [PATCH 2/9] Fix types --- .../plugins/fleet/common/types/models/agent_policy.ts | 6 ++++-- .../components/agent_policy_advanced_fields/index.tsx | 11 +++++------ x-pack/plugins/fleet/public/types/index.ts | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) 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 96ef8b249078e..f33840d4a43b6 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -14,7 +14,9 @@ import type { PackagePolicy, PackagePolicyPackage } from './package_policy'; import type { Output } from './output'; export type AgentPolicyStatus = typeof agentPolicyStatuses; -export type AgentLoggingLevels = typeof agentLoggingLevels; + +type AgentLoggingLevelKeys = keyof typeof agentLoggingLevels; +export type AgentLoggingLevel = typeof agentLoggingLevels[AgentLoggingLevelKeys]; // adding a property here? If it should be cloned when duplicating a policy, add it to `agentPolicyService.copy` // x-pack/plugins/fleet/server/services/agent_policy.ts#L571 @@ -41,7 +43,7 @@ export interface NewAgentPolicy { is_protected?: boolean; overrides?: { [key: string]: any } | null; advanced_settings?: { [key: string]: any } | null; - logging_level?: ValueOf; + logging_level?: AgentLoggingLevel; } // SO definition for this type is declared in server/types/interfaces diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index c18d8a19f4190..d17930555b094 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -36,7 +36,7 @@ import { DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT, agentLoggingLevels, } from '../../../../../../../common/constants'; -import type { NewAgentPolicy, AgentPolicy } from '../../../../types'; +import type { NewAgentPolicy, AgentPolicy, AgentLoggingLevel } from '../../../../types'; import { useStartServices, useConfig, @@ -76,8 +76,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = isEditing = false, disabled = false, }) => { - const LEVEL_VALUES = Object.keys(agentLoggingLevels); - const { docLinks } = useStartServices(); const AgentTamperProtectionWrapper = useUIExtension( 'endpoint', @@ -437,12 +435,13 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = fullWidth onChange={(e) => { updateAgentPolicy({ - logging_level: e.target.value, + logging_level: e.target.value as AgentLoggingLevel, }); }} - options={LEVEL_VALUES.map((level) => ({ + options={Object.keys(agentLoggingLevels).map((level) => ({ text: level, - value: agentLoggingLevels[level], + // @ts-ignore-next-line + value: agentLoggingLevels[logLevel], }))} /> diff --git a/x-pack/plugins/fleet/public/types/index.ts b/x-pack/plugins/fleet/public/types/index.ts index 9f540a2c049c1..52d16fa360028 100644 --- a/x-pack/plugins/fleet/public/types/index.ts +++ b/x-pack/plugins/fleet/public/types/index.ts @@ -10,6 +10,7 @@ export type { AgentMetadata, AgentPolicy, NewAgentPolicy, + AgentLoggingLevel, SimplifiedAgentStatus, EnrollmentAPIKey, PackagePolicy, From d2f31039c8032f42023d50a996e169db715939ff Mon Sep 17 00:00:00 2001 From: criamico Date: Thu, 11 Apr 2024 16:20:45 +0200 Subject: [PATCH 3/9] Add feature flag and unit tests --- .../fleet/common/experimental_features.ts | 1 + .../fleet/common/types/models/agent_policy.ts | 5 +- .../index.test.tsx | 20 ++++ .../agent_policy_advanced_fields/index.tsx | 103 ++++++++++-------- .../agent_policies/full_agent_policy.test.ts | 39 +++++++ .../agent_policies/full_agent_policy.ts | 6 + 6 files changed, 129 insertions(+), 45 deletions(-) diff --git a/x-pack/plugins/fleet/common/experimental_features.ts b/x-pack/plugins/fleet/common/experimental_features.ts index a12711012f307..0f9f6d6ebcfc1 100644 --- a/x-pack/plugins/fleet/common/experimental_features.ts +++ b/x-pack/plugins/fleet/common/experimental_features.ts @@ -30,6 +30,7 @@ export const allowedExperimentalValues = Object.freeze>( subfeaturePrivileges: false, enablePackagesStateMachine: true, advancedPolicySettings: true, + showAgentLoggingPerPolicy: false, }); type ExperimentalConfigKeys = Array; 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 f33840d4a43b6..b8dc2a51fd5e8 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -43,7 +43,7 @@ export interface NewAgentPolicy { is_protected?: boolean; overrides?: { [key: string]: any } | null; advanced_settings?: { [key: string]: any } | null; - logging_level?: AgentLoggingLevel; + logging_level?: AgentLoggingLevel | null; } // SO definition for this type is declared in server/types/interfaces @@ -125,6 +125,9 @@ export interface FullAgentPolicy { uninstall_token_hash: string; signing_key: string; }; + logging?: { + level: AgentLoggingLevel; + }; }; secret_references?: PolicySecretReference[]; signed?: { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx index 1fa4b2176f1ab..799b4840c7d2d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx @@ -20,6 +20,7 @@ import { useLicense } from '../../../../../../hooks/use_license'; import type { LicenseService } from '../../../../../../../common/services'; import { generateNewAgentPolicyWithDefaults } from '../../../../../../../common/services'; +import { ExperimentalFeaturesService } from '../../../../../../services'; import type { ValidationResults } from '../agent_policy_validation'; @@ -78,6 +79,25 @@ describe('Agent policy advanced options content', () => { jest.resetAllMocks(); }); + describe('Agent logging select', () => { + usePlatinumLicense(); + it('should be visible if feature flag is enabled', () => { + jest + .spyOn(ExperimentalFeaturesService, 'get') + .mockReturnValue({ showAgentLoggingPerPolicy: true }); + render(); + expect(renderResult.queryByTestId('agentLoggingSelect')).toBeInTheDocument(); + }); + + it('should not be visible if feature flag is disabled', () => { + jest + .spyOn(ExperimentalFeaturesService, 'get') + .mockReturnValue({ showAgentLoggingPerPolicy: false }); + render(); + expect(renderResult.queryByTestId('agentLoggingSelect')).not.toBeInTheDocument(); + }); + }); + describe('Agent tamper protection toggle', () => { it('should be visible if license is at least platinum', () => { usePlatinumLicense(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index d17930555b094..ece2157c31b7c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -112,7 +112,8 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = // agent monitoring checkbox group can appear multiple times in the DOM, ids have to be unique to work correctly const monitoringCheckboxIdSuffix = Date.now(); - const { agentTamperProtectionEnabled } = ExperimentalFeaturesService.get(); + const { agentTamperProtectionEnabled, showAgentLoggingPerPolicy } = + ExperimentalFeaturesService.get(); const licenseService = useLicense(); const [isUninstallCommandFlyoutOpen, setIsUninstallCommandFlyoutOpen] = useState(false); const policyHasElasticDefend = useMemo(() => hasElasticDefend(agentPolicy), [agentPolicy]); @@ -209,6 +210,62 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = AgentTamperProtectionSectionContent, ]); + const AgentLoggingSection = useMemo(() => { + return showAgentLoggingPerPolicy ? ( + + + + } + description={ + + } + > + + { + updateAgentPolicy({ + logging_level: e.target.value as AgentLoggingLevel, + }); + }} + options={Object.keys(agentLoggingLevels).map((level) => ({ + text: level, + // @ts-ignore-next-line + value: agentLoggingLevels[level], + }))} + /> + + + ) : null; + }, [ + agentPolicy.logging_level, + disabled, + showAgentLoggingPerPolicy, + touchedFields.agentLogLevel, + updateAgentPolicy, + validation.agentLogLevel, + ]); + return ( <> = }} /> - - - - } - description={ - - } - > - - { - updateAgentPolicy({ - logging_level: e.target.value as AgentLoggingLevel, - }); - }} - options={Object.keys(agentLoggingLevels).map((level) => ({ - text: level, - // @ts-ignore-next-line - value: agentLoggingLevels[logLevel], - }))} - /> - - + {AgentLoggingSection} {AgentTamperProtectionSection} { }, }); }); + + it('should return agent logging level if logging_level is present in the policy', async () => { + mockAgentPolicy({ + logging_level: 'debug', + }); + const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); + + expect(agentPolicy).toMatchObject({ + id: 'agent-policy', + agent: { + logging: { level: 'debug' }, + }, + }); + }); + + it('should retrun agent logging level and advanced settings if both are present', async () => { + mockAgentPolicy({ + logging_level: 'warning', + advanced_settings: { + agent_limits_go_max_procs: 2, + agent_download_timeout: '60s', + agent_download_target_directory: '/tmp', + agent_logging_metrics_period: '10s', + }, + }); + const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); + + expect(agentPolicy).toMatchObject({ + id: 'agent-policy', + agent: { + download: { + timeout: '60s', + target_directory: '/tmp', + }, + limits: { go_max_procs: 2 }, + logging: { level: 'warning', metrics: { period: '10s' } }, + }, + }); + }); }); describe('transformOutputToFullPolicyOutput', () => { diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts index bec47eea524c4..27d5a0a7e17d3 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts @@ -287,6 +287,12 @@ export async function getFullAgentPolicy( }; } + if (agentPolicy.logging_level) { + fullAgentPolicy.agent = { + ...fullAgentPolicy.agent, + logging: { ...fullAgentPolicy.agent?.logging, level: agentPolicy.logging_level }, + }; + } if (agentPolicy.overrides) { return deepMerge(fullAgentPolicy, agentPolicy.overrides); } From 2c0a1f9bc546c618504f91fc7e03a5d02d79513a Mon Sep 17 00:00:00 2001 From: criamico Date: Fri, 12 Apr 2024 09:42:17 +0200 Subject: [PATCH 4/9] Fix submit policy and remove leftover props --- .../components/agent_policy_advanced_fields/index.tsx | 8 +------- .../components/agent_policy_create_inline.tsx | 1 - .../agent_policy/components/agent_policy_form.tsx | 2 -- .../agent_policy/components/agent_policy_integration.tsx | 5 ----- .../details_page/components/settings/index.tsx | 1 + x-pack/plugins/fleet/server/services/agent_policy.ts | 1 + 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index ece2157c31b7c..6752550af2e4e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -65,7 +65,6 @@ interface Props { agentPolicy: Partial; updateAgentPolicy: (u: Partial) => void; validation: ValidationResults; - isEditing?: boolean; disabled?: boolean; } @@ -73,7 +72,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = agentPolicy, updateAgentPolicy, validation, - isEditing = false, disabled = false, }) => { const { docLinks } = useStartServices(); @@ -230,11 +228,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = > @@ -252,6 +245,7 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = text: level, // @ts-ignore-next-line value: agentLoggingLevels[level], + key: level, }))} /> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_create_inline.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_create_inline.tsx index 74a71347b41f0..dde879ab336b9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_create_inline.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_create_inline.tsx @@ -188,7 +188,6 @@ export const AgentPolicyCreateInlineForm: React.FunctionComponent = ({ agentPolicy={newAgentPolicy} updateAgentPolicy={updateNewAgentPolicy} validation={validation} - isEditing={false} /> 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 8a0d92b159207..97fc1fc28acf9 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 @@ -141,7 +141,6 @@ export const AgentPolicyForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} /> {advancedPolicySettings ? ( @@ -168,7 +167,6 @@ export const AgentPolicyForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} disabled={disabled} /> {advancedPolicySettings ? ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx index 759c85b54a181..5de23cd555198 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx @@ -35,8 +35,6 @@ interface Props { withSysMonitoring: boolean; updateSysMonitoring: (newValue: boolean) => void; validation: ValidationResults; - isEditing?: boolean; - onDelete?: () => void; } export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ @@ -45,8 +43,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ withSysMonitoring, updateSysMonitoring, validation, - isEditing = false, - onDelete = () => {}, }) => { return ( @@ -101,7 +97,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} /> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx index f9ca5fa24226c..6f6543a5d5373 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx @@ -53,6 +53,7 @@ const pickAgentPolicyKeysToSend = (agentPolicy: AgentPolicy) => 'agent_features', 'is_protected', 'advanced_settings', + 'logging_level', ]); const FormWrapper = styled.div` diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index 4bc0fd024f79f..a1e1be7f032d7 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -653,6 +653,7 @@ class AgentPolicyService { 'monitoring_output_id', 'download_source_id', 'fleet_server_host_id', + 'logging_level', ]), ...newAgentPolicyProps, }, From a3c6e2581fcfccb382668294a2eed0fd5c2f6fab Mon Sep 17 00:00:00 2001 From: criamico Date: Fri, 12 Apr 2024 16:02:57 +0200 Subject: [PATCH 5/9] Move logging level select under advanced features section --- .../fleet/common/experimental_features.ts | 1 - .../common/settings/agent_policy_settings.ts | 15 +++++ .../fleet/common/types/models/agent_policy.ts | 1 - .../fleet/components/form_settings/index.tsx | 22 +++++++ .../index.test.tsx | 20 ------- .../agent_policy_advanced_fields/index.tsx | 60 +------------------ .../components/settings/index.tsx | 1 - .../fleet/server/saved_objects/index.ts | 1 - .../agent_policies/full_agent_policy.test.ts | 39 +----------- .../agent_policies/full_agent_policy.ts | 6 -- .../fleet/server/services/agent_policy.ts | 1 - .../fleet/server/types/models/agent_policy.ts | 12 +--- 12 files changed, 41 insertions(+), 138 deletions(-) diff --git a/x-pack/plugins/fleet/common/experimental_features.ts b/x-pack/plugins/fleet/common/experimental_features.ts index 0f9f6d6ebcfc1..a12711012f307 100644 --- a/x-pack/plugins/fleet/common/experimental_features.ts +++ b/x-pack/plugins/fleet/common/experimental_features.ts @@ -30,7 +30,6 @@ export const allowedExperimentalValues = Object.freeze>( subfeaturePrivileges: false, enablePackagesStateMachine: true, advancedPolicySettings: true, - showAgentLoggingPerPolicy: false, }); type ExperimentalConfigKeys = Array; diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts index f0d7a84d36d2a..3263d797707bd 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts @@ -8,6 +8,8 @@ import { i18n } from '@kbn/i18n'; import { z } from 'zod'; +import { agentLoggingLevels } from '../constants'; + import type { SettingsConfig } from './types'; export const zodStringWithDurationValidation = z @@ -37,4 +39,17 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ }, schema: z.number().int().min(0).default(0), }, + { + name: 'agent.logging.level', + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevel', { + defaultMessage: 'Agent Logging Level', + }), + description: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.goMaxProcsDescription', { + defaultMessage: 'Set the Agent log level. The default log level is "info".', + }), + api_field: { + name: 'agent_logging_level', + }, + schema: z.nativeEnum(agentLoggingLevels), + }, ]; 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 b8dc2a51fd5e8..ac9a596e3125e 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -43,7 +43,6 @@ export interface NewAgentPolicy { is_protected?: boolean; overrides?: { [key: string]: any } | null; advanced_settings?: { [key: string]: any } | null; - logging_level?: AgentLoggingLevel | null; } // SO definition for this type is declared in server/types/interfaces diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx index 03d66d23615ba..1129ec256723d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx @@ -13,6 +13,7 @@ import { EuiFieldText, EuiFormRow, EuiLink, + EuiSelect, } from '@elastic/eui'; import type { SettingsConfig } from '../../../../../common/settings/types'; @@ -61,6 +62,27 @@ settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodString, (settingsConfig) = ); }); +settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodNativeEnum, (settingsConfig) => { + return ( + ( + ({ + text: level, + value: coercedSchema.enum[level], + }))} + /> + )} + /> + ); +}); + const SettingsFieldWrapper: React.FC<{ settingsConfig: SettingsConfig; typeName: keyof typeof ZodFirstPartyTypeKind; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx index 799b4840c7d2d..1fa4b2176f1ab 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.test.tsx @@ -20,7 +20,6 @@ import { useLicense } from '../../../../../../hooks/use_license'; import type { LicenseService } from '../../../../../../../common/services'; import { generateNewAgentPolicyWithDefaults } from '../../../../../../../common/services'; -import { ExperimentalFeaturesService } from '../../../../../../services'; import type { ValidationResults } from '../agent_policy_validation'; @@ -79,25 +78,6 @@ describe('Agent policy advanced options content', () => { jest.resetAllMocks(); }); - describe('Agent logging select', () => { - usePlatinumLicense(); - it('should be visible if feature flag is enabled', () => { - jest - .spyOn(ExperimentalFeaturesService, 'get') - .mockReturnValue({ showAgentLoggingPerPolicy: true }); - render(); - expect(renderResult.queryByTestId('agentLoggingSelect')).toBeInTheDocument(); - }); - - it('should not be visible if feature flag is disabled', () => { - jest - .spyOn(ExperimentalFeaturesService, 'get') - .mockReturnValue({ showAgentLoggingPerPolicy: false }); - render(); - expect(renderResult.queryByTestId('agentLoggingSelect')).not.toBeInTheDocument(); - }); - }); - describe('Agent tamper protection toggle', () => { it('should be visible if license is at least platinum', () => { usePlatinumLicense(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index 6752550af2e4e..08049f6d81669 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -25,7 +25,6 @@ import { EuiBetaBadge, EuiBadge, EuiSwitch, - EuiSelect, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; @@ -34,9 +33,8 @@ import { AGENT_POLICY_SAVED_OBJECT_TYPE, dataTypes, DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT, - agentLoggingLevels, } from '../../../../../../../common/constants'; -import type { NewAgentPolicy, AgentPolicy, AgentLoggingLevel } from '../../../../types'; +import type { NewAgentPolicy, AgentPolicy } from '../../../../types'; import { useStartServices, useConfig, @@ -110,8 +108,7 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = // agent monitoring checkbox group can appear multiple times in the DOM, ids have to be unique to work correctly const monitoringCheckboxIdSuffix = Date.now(); - const { agentTamperProtectionEnabled, showAgentLoggingPerPolicy } = - ExperimentalFeaturesService.get(); + const { agentTamperProtectionEnabled } = ExperimentalFeaturesService.get(); const licenseService = useLicense(); const [isUninstallCommandFlyoutOpen, setIsUninstallCommandFlyoutOpen] = useState(false); const policyHasElasticDefend = useMemo(() => hasElasticDefend(agentPolicy), [agentPolicy]); @@ -208,58 +205,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = AgentTamperProtectionSectionContent, ]); - const AgentLoggingSection = useMemo(() => { - return showAgentLoggingPerPolicy ? ( - - - - } - description={ - - } - > - - { - updateAgentPolicy({ - logging_level: e.target.value as AgentLoggingLevel, - }); - }} - options={Object.keys(agentLoggingLevels).map((level) => ({ - text: level, - // @ts-ignore-next-line - value: agentLoggingLevels[level], - key: level, - }))} - /> - - - ) : null; - }, [ - agentPolicy.logging_level, - disabled, - showAgentLoggingPerPolicy, - touchedFields.agentLogLevel, - updateAgentPolicy, - validation.agentLogLevel, - ]); - return ( <> = }} /> - {AgentLoggingSection} {AgentTamperProtectionSection} 'agent_features', 'is_protected', 'advanced_settings', - 'logging_level', ]); const FormWrapper = styled.div` diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index e8060f340e05b..787137cacba18 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -158,7 +158,6 @@ export const getSavedObjectTypes = (): { [key: string]: SavedObjectsType } => ({ overrides: { type: 'flattened', index: false }, keep_monitoring_alive: { type: 'boolean' }, advanced_settings: { type: 'flattened', index: false }, - logging_level: { type: 'keyword', index: false }, }, }, migrations: { diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts index a9ce3f6131c02..c85a211fb49a8 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts @@ -719,6 +719,7 @@ describe('getFullAgentPolicy', () => { mockAgentPolicy({ advanced_settings: { agent_limits_go_max_procs: 2, + agent_logging_level: 'debug', }, }); const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); @@ -727,48 +728,10 @@ describe('getFullAgentPolicy', () => { id: 'agent-policy', agent: { limits: { go_max_procs: 2 }, - }, - }); - }); - - it('should return agent logging level if logging_level is present in the policy', async () => { - mockAgentPolicy({ - logging_level: 'debug', - }); - const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); - - expect(agentPolicy).toMatchObject({ - id: 'agent-policy', - agent: { logging: { level: 'debug' }, }, }); }); - - it('should retrun agent logging level and advanced settings if both are present', async () => { - mockAgentPolicy({ - logging_level: 'warning', - advanced_settings: { - agent_limits_go_max_procs: 2, - agent_download_timeout: '60s', - agent_download_target_directory: '/tmp', - agent_logging_metrics_period: '10s', - }, - }); - const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); - - expect(agentPolicy).toMatchObject({ - id: 'agent-policy', - agent: { - download: { - timeout: '60s', - target_directory: '/tmp', - }, - limits: { go_max_procs: 2 }, - logging: { level: 'warning', metrics: { period: '10s' } }, - }, - }); - }); }); describe('transformOutputToFullPolicyOutput', () => { diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts index 27d5a0a7e17d3..bec47eea524c4 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts @@ -287,12 +287,6 @@ export async function getFullAgentPolicy( }; } - if (agentPolicy.logging_level) { - fullAgentPolicy.agent = { - ...fullAgentPolicy.agent, - logging: { ...fullAgentPolicy.agent?.logging, level: agentPolicy.logging_level }, - }; - } if (agentPolicy.overrides) { return deepMerge(fullAgentPolicy, agentPolicy.overrides); } diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index a1e1be7f032d7..4bc0fd024f79f 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -653,7 +653,6 @@ class AgentPolicyService { 'monitoring_output_id', 'download_source_id', 'fleet_server_host_id', - 'logging_level', ]), ...newAgentPolicyProps, }, diff --git a/x-pack/plugins/fleet/server/types/models/agent_policy.ts b/x-pack/plugins/fleet/server/types/models/agent_policy.ts index 054c4b90dd402..748a5c81c1bfb 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -7,7 +7,7 @@ import { schema } from '@kbn/config-schema'; -import { agentPolicyStatuses, dataTypes, agentLoggingLevels } from '../../../common/constants'; +import { agentPolicyStatuses, dataTypes } from '../../../common/constants'; import { isValidNamespace } from '../../../common/services'; import { getSettingsAPISchema } from '../../services/form_settings'; @@ -62,16 +62,6 @@ export const AgentPolicyBaseSchema = { monitoring_output_id: schema.maybe(schema.nullable(schema.string())), download_source_id: schema.maybe(schema.nullable(schema.string())), fleet_server_host_id: schema.maybe(schema.nullable(schema.string())), - logging_level: schema.maybe( - schema.nullable( - schema.oneOf([ - schema.literal(agentLoggingLevels.Info), - schema.literal(agentLoggingLevels.Debug), - schema.literal(agentLoggingLevels.Warning), - schema.literal(agentLoggingLevels.Error), - ]) - ) - ), agent_features: schema.maybe( schema.arrayOf( schema.object({ From 08ab93893d702f6d8f97059687f67e66ff5fb696 Mon Sep 17 00:00:00 2001 From: criamico Date: Fri, 12 Apr 2024 16:33:31 +0200 Subject: [PATCH 6/9] Remove unused types --- x-pack/plugins/fleet/common/types/models/agent_policy.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 ac9a596e3125e..60e635f73f6cc 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -7,7 +7,7 @@ import type { SecurityRoleDescriptor } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { agentPolicyStatuses, agentLoggingLevels } from '../../constants'; +import type { agentPolicyStatuses } from '../../constants'; import type { MonitoringType, PolicySecretReference, ValueOf } from '..'; import type { PackagePolicy, PackagePolicyPackage } from './package_policy'; @@ -15,9 +15,6 @@ import type { Output } from './output'; export type AgentPolicyStatus = typeof agentPolicyStatuses; -type AgentLoggingLevelKeys = keyof typeof agentLoggingLevels; -export type AgentLoggingLevel = typeof agentLoggingLevels[AgentLoggingLevelKeys]; - // adding a property here? If it should be cloned when duplicating a policy, add it to `agentPolicyService.copy` // x-pack/plugins/fleet/server/services/agent_policy.ts#L571 export interface NewAgentPolicy { @@ -124,9 +121,6 @@ export interface FullAgentPolicy { uninstall_token_hash: string; signing_key: string; }; - logging?: { - level: AgentLoggingLevel; - }; }; secret_references?: PolicySecretReference[]; signed?: { From fbd1788b92c902f38312b306d09a2fcc332d3bd6 Mon Sep 17 00:00:00 2001 From: criamico Date: Mon, 15 Apr 2024 10:10:24 +0200 Subject: [PATCH 7/9] Address code review comments --- .../plugins/fleet/common/constants/agent_policy.ts | 9 +++++++++ .../fleet/common/settings/agent_policy_settings.ts | 13 ++++++++----- .../components/agent_logs/constants.tsx | 9 --------- .../components/agent_logs/filter_log_level.tsx | 2 +- .../components/agent_logs/select_log_level.tsx | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/fleet/common/constants/agent_policy.ts b/x-pack/plugins/fleet/common/constants/agent_policy.ts index 4a8a9fc1c6927..b2cbed6bb68e9 100644 --- a/x-pack/plugins/fleet/common/constants/agent_policy.ts +++ b/x-pack/plugins/fleet/common/constants/agent_policy.ts @@ -38,6 +38,15 @@ export const DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT = 750; export const AGENTLESS_POLICY_ID = 'agentless'; // the policy id defined here: https://github.com/elastic/project-controller/blob/main/internal/project/security/security_kibana_config.go#L86 +export const AGENT_LOG_LEVELS = { + ERROR: 'error', + WARNING: 'warning', + INFO: 'info', + DEBUG: 'debug', +}; + +export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO; + export const agentLoggingLevels = { Info: 'info', Debug: 'debug', diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts index 1c1d8a3fcccd7..9ee3c5168b552 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts @@ -131,15 +131,18 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ { name: 'agent.logging.level', hidden: true, - title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevel', { + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', { defaultMessage: 'Agent Logging Level', }), - description: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.goMaxProcsDescription', { - defaultMessage: 'Set the Agent log level. The default log level is "info".', - }), + description: i18n.translate( + 'xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelDescription', + { + defaultMessage: 'Set the Agent log level. The default log level is "info".', + } + ), api_field: { name: 'agent_logging_level', }, - schema: z.nativeEnum(agentLoggingLevels), + schema: z.nativeEnum(agentLoggingLevels).default(agentLoggingLevels.Info), }, ]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx index bee26f7c5b067..c15c722f7aa4b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx @@ -48,12 +48,3 @@ export const DEFAULT_LOGS_STATE: AgentLogsState = { export const STATE_STORAGE_KEY = '_q'; export const STATE_DATASET_FIELD = 'datasets'; - -export const AGENT_LOG_LEVELS = { - ERROR: 'error', - WARNING: 'warning', - INFO: 'info', - DEBUG: 'debug', -}; - -export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx index b4971ec4b2209..e565ddccc4b70 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx @@ -10,7 +10,7 @@ import type { EuiSelectableOption } from '@elastic/eui'; import { EuiPopover, EuiFilterButton, EuiSelectable } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AGENT_LOG_LEVELS } from './constants'; +import { AGENT_LOG_LEVELS } from '../../../../../../../../common/constants'; const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx index c442925960977..4c32952339347 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx @@ -13,7 +13,7 @@ import { EuiSelect, EuiFormLabel, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } fr import type { Agent } from '../../../../../types'; import { sendPostAgentAction, useAuthz, useStartServices } from '../../../../../hooks'; -import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from './constants'; +import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from '../../../../../../../../common/constants'; const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS); From 093194d36531223b0c9fb25f5b6822631f69befd Mon Sep 17 00:00:00 2001 From: criamico Date: Mon, 15 Apr 2024 10:48:30 +0200 Subject: [PATCH 8/9] Fix linter and error in UI --- x-pack/plugins/fleet/common/settings/agent_policy_settings.ts | 4 ++-- x-pack/plugins/fleet/public/types/index.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts index 9ee3c5168b552..1be6a56e4a599 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts @@ -130,7 +130,7 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ }, { name: 'agent.logging.level', - hidden: true, + hidden: false, title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', { defaultMessage: 'Agent Logging Level', }), @@ -143,6 +143,6 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ api_field: { name: 'agent_logging_level', }, - schema: z.nativeEnum(agentLoggingLevels).default(agentLoggingLevels.Info), + schema: z.nativeEnum(agentLoggingLevels), }, ]; diff --git a/x-pack/plugins/fleet/public/types/index.ts b/x-pack/plugins/fleet/public/types/index.ts index 52d16fa360028..9f540a2c049c1 100644 --- a/x-pack/plugins/fleet/public/types/index.ts +++ b/x-pack/plugins/fleet/public/types/index.ts @@ -10,7 +10,6 @@ export type { AgentMetadata, AgentPolicy, NewAgentPolicy, - AgentLoggingLevel, SimplifiedAgentStatus, EnrollmentAPIKey, PackagePolicy, From b3657acd47d04e89417f05ef19ae4e3154114496 Mon Sep 17 00:00:00 2001 From: criamico Date: Mon, 15 Apr 2024 10:49:27 +0200 Subject: [PATCH 9/9] set hidden to true --- x-pack/plugins/fleet/common/settings/agent_policy_settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts index 1be6a56e4a599..9d23f948da3e6 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts @@ -130,7 +130,7 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ }, { name: 'agent.logging.level', - hidden: false, + hidden: true, title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', { defaultMessage: 'Agent Logging Level', }),