diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index d30ac3c4552e2..9b446eacf7bb9 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -6355,18 +6355,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -7113,18 +7122,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -7361,18 +7379,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -8145,18 +8172,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -9190,18 +9226,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -9947,18 +9992,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -10195,18 +10249,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -10980,18 +11043,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -11890,6 +11962,42 @@ }, "type": "object" }, + "limits": { + "additionalProperties": false, + "properties": { + "go_max_procs": { + "type": "number" + } + }, + "type": "object" + }, + "logging": { + "additionalProperties": false, + "properties": { + "files": { + "additionalProperties": false, + "properties": { + "interval": { + "type": "string" + }, + "keepfiles": { + "type": "number" + }, + "rotateeverybytes": { + "type": "number" + } + }, + "type": "object" + }, + "level": { + "type": "string" + }, + "to_files": { + "type": "boolean" + } + }, + "type": "object" + }, "monitoring": { "additionalProperties": false, "properties": { diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 4b56e3581c66f..7adb2e8140491 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -6355,18 +6355,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -7113,18 +7122,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -7361,18 +7379,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -8145,18 +8172,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -9190,18 +9226,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -9947,18 +9992,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -10195,18 +10249,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -10980,18 +11043,27 @@ "nullable": true }, "agent_download_timeout": { - "default": "2h", "nullable": true }, "agent_limits_go_max_procs": { "nullable": true }, + "agent_logging_files_interval": { + "nullable": true + }, + "agent_logging_files_keepfiles": { + "nullable": true + }, + "agent_logging_files_rotateeverybytes": { + "nullable": true + }, "agent_logging_level": { - "default": "info", "nullable": true }, "agent_logging_metrics_period": { - "default": "30s", + "nullable": true + }, + "agent_logging_to_files": { "nullable": true } }, @@ -11890,6 +11962,42 @@ }, "type": "object" }, + "limits": { + "additionalProperties": false, + "properties": { + "go_max_procs": { + "type": "number" + } + }, + "type": "object" + }, + "logging": { + "additionalProperties": false, + "properties": { + "files": { + "additionalProperties": false, + "properties": { + "interval": { + "type": "string" + }, + "keepfiles": { + "type": "number" + }, + "rotateeverybytes": { + "type": "number" + } + }, + "type": "object" + }, + "level": { + "type": "string" + }, + "to_files": { + "type": "boolean" + } + }, + "type": "object" + }, "monitoring": { "additionalProperties": false, "properties": { diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 4b35e4d9c78fc..fb16ca36cf59e 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -9522,15 +9522,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -10047,15 +10052,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -10221,15 +10231,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -10765,15 +10780,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -11289,15 +11309,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -11813,15 +11838,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -11987,15 +12017,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -12531,15 +12566,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -13153,6 +13193,30 @@ paths: required: - enabled type: object + limits: + additionalProperties: false + type: object + properties: + go_max_procs: + type: number + logging: + additionalProperties: false + type: object + properties: + files: + additionalProperties: false + type: object + properties: + interval: + type: string + keepfiles: + type: number + rotateeverybytes: + type: number + level: + type: string + to_files: + type: boolean monitoring: additionalProperties: false type: object diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index 94e987510c649..322160b6231cc 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -12378,15 +12378,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -12902,15 +12907,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -13076,15 +13086,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -13619,15 +13634,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -14142,15 +14162,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -14665,15 +14690,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -14839,15 +14869,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -15382,15 +15417,20 @@ paths: agent_download_target_directory: nullable: true agent_download_timeout: - default: 2h nullable: true agent_limits_go_max_procs: nullable: true + agent_logging_files_interval: + nullable: true + agent_logging_files_keepfiles: + nullable: true + agent_logging_files_rotateeverybytes: + nullable: true agent_logging_level: - default: info nullable: true agent_logging_metrics_period: - default: 30s + nullable: true + agent_logging_to_files: nullable: true agent_features: items: @@ -16002,6 +16042,30 @@ paths: required: - enabled type: object + limits: + additionalProperties: false + type: object + properties: + go_max_procs: + type: number + logging: + additionalProperties: false + type: object + properties: + files: + additionalProperties: false + type: object + properties: + interval: + type: string + keepfiles: + type: number + rotateeverybytes: + type: number + level: + type: string + to_files: + type: boolean monitoring: additionalProperties: false type: object diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx b/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx index a4b41979840b2..55a5885fa4e6b 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx @@ -40,7 +40,7 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ api_field: { name: 'agent_limits_go_max_procs', }, - schema: z.number().int().min(0).default(0), + schema: z.number().int().min(0), }, { name: 'agent.download.timeout', @@ -59,7 +59,7 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ api_field: { name: 'agent_download_timeout', }, - schema: zodStringWithDurationValidation.default('2h'), + schema: zodStringWithDurationValidation, }, { name: 'agent.download.target_directory', @@ -103,7 +103,7 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ ), learnMoreLink: 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', - schema: zodStringWithDurationValidation.default('30s'), + schema: zodStringWithDurationValidation, }, { name: 'agent.logging.level', @@ -124,4 +124,76 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ 'https://www.elastic.co/guide/en/fleet/current/agent-policy.html#agent-policy-log-level', schema: z.enum(AGENT_LOG_LEVELS).default(DEFAULT_LOG_LEVEL), }, + { + name: 'agent.logging.to_files', + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingToFilesTitle', { + defaultMessage: 'Agent logging to files', + }), + description: ( + + ), + api_field: { + name: 'agent_logging_to_files', + }, + learnMoreLink: + 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', + schema: z.boolean().default(true), + }, + { + name: 'agent.logging.files.rotateeverybytes', + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingFileSizeTitle', { + defaultMessage: 'Agent logging file size limit', + }), + description: ( + + ), + api_field: { + name: 'agent_logging_files_rotateeverybytes', + }, + learnMoreLink: + 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', + schema: z.number().int().min(0), + }, + { + name: 'agent.logging.files.keepfiles', + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingFileLimitTitle', { + defaultMessage: 'Agent logging number of files', + }), + description: ( + + ), + api_field: { + name: 'agent_logging_files_keepfiles', + }, + learnMoreLink: + 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', + schema: z.number().int().min(0), + }, + { + name: 'agent.logging.files.interval', + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingFileIntervalitle', { + defaultMessage: 'Agent logging number of files', + }), + description: ( + + ), + api_field: { + name: 'agent_logging_files_interval', + }, + learnMoreLink: + 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', + schema: zodStringWithDurationValidation, + }, ]; 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 ba1a0b182af72..841b98b239b29 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -185,6 +185,18 @@ export interface FullAgentPolicy { uninstall_token_hash: string; signing_key: string; }; + logging?: { + level?: string; + to_files?: boolean; + files?: { + rotateeverybytes?: number; + keepfiles?: number; + interval?: string; + }; + }; + limits?: { + go_max_procs?: number; + }; }; secret_references?: PolicySecretReference[]; signed?: { diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.test.tsx index 8bafc124ec36b..768f9f913607d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.test.tsx @@ -102,6 +102,35 @@ describe('ConfiguredSettings', () => { expect(mockUpdateAdvancedSettingsHasErrors).toHaveBeenCalledWith(true); }); + it('should render boolean field using checkbox', () => { + const result = render([ + { + name: 'agent.logging.to_files', + title: 'Agent logging to files', + description: 'Description', + learnMoreLink: '', + api_field: { + name: 'agent_logging_to_files', + }, + schema: z.boolean().default(false), + }, + ]); + + expect(result.getByText('Agent logging to files')).not.toBeNull(); + const input = result.getByTestId('configuredSetting-agent.logging.to_files'); + expect(input).not.toBeChecked(); + + act(() => { + fireEvent.click(input); + }); + + expect(mockUpdateAgentPolicy).toHaveBeenCalledWith( + expect.objectContaining({ + advanced_settings: expect.objectContaining({ agent_logging_to_files: true }), + }) + ); + }); + it('should not render field if hidden', () => { const result = render([ { 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 7ebf80141c554..e93dd0b6cdd82 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 @@ -7,7 +7,9 @@ import { ZodFirstPartyTypeKind } from '@kbn/zod'; import React from 'react'; -import { EuiFieldNumber, EuiFieldText, EuiSelect } from '@elastic/eui'; +import { EuiCheckbox, EuiFieldNumber, EuiFieldText, EuiSelect } from '@elastic/eui'; + +import { i18n } from '@kbn/i18n'; import type { SettingsConfig } from '../../../../../common/settings/types'; @@ -68,7 +70,7 @@ settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodEnum, ({ disabled, ...sett ( { + return ( + ( + + )} + /> + ); + } +); + export function ConfiguredSettings({ configuredSettings, disabled, @@ -101,7 +127,7 @@ export function ConfiguredSettings({ const Component = settingComponentRegistry.get(getInnerType(configuredSetting.schema)); if (!Component) { - throw new Error(`Unknown setting type: ${configuredSetting.schema._type}}`); + throw new Error(`Unknown setting type: ${configuredSetting.schema._type}`); } return ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/settings_field_wrapper.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/settings_field_wrapper.tsx index 61adef4729a27..1885d466711fb 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/settings_field_wrapper.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/settings_field_wrapper.tsx @@ -13,12 +13,15 @@ import { EuiDescribedFormGroup, EuiFormRow, EuiLink } from '@elastic/eui'; import type { SettingsConfig } from '../../../../../common/settings/types'; import { useAgentPolicyFormContext } from '../../sections/agent_policy/components/agent_policy_form'; -export const convertValue = (value: string, type: keyof typeof ZodFirstPartyTypeKind): any => { +export const convertValue = ( + value: string | boolean, + type: keyof typeof ZodFirstPartyTypeKind +): any => { if (type === ZodFirstPartyTypeKind.ZodNumber) { if (value === '') { return 0; } - return parseInt(value, 10); + return parseInt(value as string, 10); } return value; }; @@ -48,7 +51,8 @@ export const SettingsFieldWrapper: React.FC<{ const coercedSchema = settingsConfig.schema as z.ZodString; const handleChange = (e: React.ChangeEvent) => { - const newValue = convertValue(e.target.value, typeName); + const value = typeName === ZodFirstPartyTypeKind.ZodBoolean ? e.target.checked : e.target.value; + const newValue = convertValue(value, typeName); const validationError = validateSchema(coercedSchema, newValue); if (validationError) { @@ -97,9 +101,13 @@ export const SettingsFieldWrapper: React.FC<{ }; export const getInnerType = (schema: z.ZodType) => { - return schema instanceof z.ZodDefault - ? schema._def.innerType._def.typeName === 'ZodEffects' + if (schema._def.innerType) { + return schema._def.innerType._def.typeName === 'ZodEffects' ? schema._def.innerType._def.schema._def.typeName - : schema._def.innerType._def.typeName - : schema._def.typeName; + : schema._def.innerType._def.typeName; + } + if (schema._def.typeName === 'ZodEffects') { + return schema._def.schema._def.typeName; + } + return schema._def.typeName; }; diff --git a/x-pack/plugins/fleet/server/routes/agent_policy/index.test.ts b/x-pack/plugins/fleet/server/routes/agent_policy/index.test.ts index 44d15317d6162..a8150b26af5f5 100644 --- a/x-pack/plugins/fleet/server/routes/agent_policy/index.test.ts +++ b/x-pack/plugins/fleet/server/routes/agent_policy/index.test.ts @@ -171,6 +171,10 @@ describe('schema validation', () => { agent_limits_go_max_procs: 1, agent_logging_level: 'info', agent_logging_metrics_period: '30s', + agent_logging_to_files: true, + agent_logging_files_rotateeverybytes: 10000, + agent_logging_files_keepfiles: 10, + agent_logging_files_interval: '7h', }, keep_monitoring_alive: true, supports_agentless: true, 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 688320825326a..96fd29b9534c6 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 @@ -888,6 +888,10 @@ describe('getFullAgentPolicy', () => { advanced_settings: { agent_limits_go_max_procs: 2, agent_logging_level: 'debug', + agent_logging_to_files: true, + agent_logging_files_rotateeverybytes: 10000, + agent_logging_files_keepfiles: 10, + agent_logging_files_interval: '7h', }, }); const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); @@ -896,7 +900,11 @@ describe('getFullAgentPolicy', () => { id: 'agent-policy', agent: { limits: { go_max_procs: 2 }, - logging: { level: 'debug' }, + logging: { + level: 'debug', + to_files: true, + files: { rotateeverybytes: 10000, keepfiles: 10, interval: '7h' }, + }, }, }); }); diff --git a/x-pack/plugins/fleet/server/services/form_settings/form_settings.test.ts b/x-pack/plugins/fleet/server/services/form_settings/form_settings.test.ts index afcba824f1a33..710d862bf3ad1 100644 --- a/x-pack/plugins/fleet/server/services/form_settings/form_settings.test.ts +++ b/x-pack/plugins/fleet/server/services/form_settings/form_settings.test.ts @@ -55,10 +55,10 @@ describe('form_settings', () => { ).not.toThrow(); }); - it('generate a valid API schema for api_field with default value', () => { + it('generate a valid API schema for api_field with default value but not add the value', () => { const apiSchema = schema.object(_getSettingsAPISchema(TEST_SETTINGS)); const res = apiSchema.validate({ advanced_settings: {} }); - expect(res).toEqual({ advanced_settings: { test_foo_default_value: 'test' } }); + expect(res).toEqual({ advanced_settings: {} }); }); }); diff --git a/x-pack/plugins/fleet/server/services/form_settings/form_settings.ts b/x-pack/plugins/fleet/server/services/form_settings/form_settings.ts index 6f644afca49ac..2c625f6bd0574 100644 --- a/x-pack/plugins/fleet/server/services/form_settings/form_settings.ts +++ b/x-pack/plugins/fleet/server/services/form_settings/form_settings.ts @@ -24,40 +24,19 @@ export function _getSettingsAPISchema(settings: SettingsConfig[]): Props { if (!setting.api_field) { return; } - const defaultValueRes = setting.schema.safeParse(undefined); - const defaultValue = defaultValueRes.success ? defaultValueRes.data : undefined; - if (defaultValue) { - validations[setting.api_field.name] = schema.oneOf( - [ - schema.any({ - validate: (val: any) => { - const res = setting.schema.safeParse(val); - if (!res.success) { - return stringifyZodError(res.error); - } - }, - }), - schema.literal(null), - ], - { - defaultValue, - } - ); - } else { - validations[setting.api_field.name] = schema.maybe( - schema.oneOf([ - schema.literal(null), - schema.any({ - validate: (val: any) => { - const res = setting.schema.safeParse(val); - if (!res.success) { - return stringifyZodError(res.error); - } - }, - }), - ]) - ); - } + validations[setting.api_field.name] = schema.maybe( + schema.oneOf([ + schema.literal(null), + schema.any({ + validate: (val: any) => { + const res = setting.schema.safeParse(val); + if (!res.success) { + return stringifyZodError(res.error); + } + }, + }), + ]) + ); }); const advancedSettingsValidations: Props = { @@ -90,7 +69,7 @@ export function _getSettingsValuesForAgentPolicy( } const val = agentPolicy.advanced_settings?.[setting.api_field.name]; - if (val) { + if (val !== undefined) { settingsValues[setting.name] = val; } }); 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 e82063e775d70..4f131d00bdf38 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -377,6 +377,24 @@ export const FullAgentPolicyResponseSchema = schema.object({ signing_key: schema.string(), }) ), + logging: schema.maybe( + schema.object({ + level: schema.maybe(schema.string()), + to_files: schema.maybe(schema.boolean()), + files: schema.maybe( + schema.object({ + rotateeverybytes: schema.maybe(schema.number()), + keepfiles: schema.maybe(schema.number()), + interval: schema.maybe(schema.string()), + }) + ), + }) + ), + limits: schema.maybe( + schema.object({ + go_max_procs: schema.maybe(schema.number()), + }) + ), }) ), secret_references: schema.maybe( diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 6d1ba23a5f6c4..3e4a0f20292eb 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -3145,6 +3145,8 @@ "esqlEditor.query.EnableWordWrapLabel": "Ajouter des sauts de ligne aux barres verticales", "esqlEditor.query.errorCount": "{count} {count, plural, one {erreur} other {erreurs}}", "esqlEditor.query.errorsTitle": "Erreurs", + "esqlEditor.query.esqlQueriesCopy": "Copier la requête dans le presse-papier", + "esqlEditor.query.esqlQueriesListRun": "Exécuter la requête", "esqlEditor.query.expandLabel": "Développer", "esqlEditor.query.feedback": "Commentaires", "esqlEditor.query.hideQueriesLabel": "Masquer les recherches récentes", @@ -3154,8 +3156,6 @@ "esqlEditor.query.lineNumber": "Ligne {lineNumber}", "esqlEditor.query.querieshistory.error": "La requête a échouée", "esqlEditor.query.querieshistory.success": "La requête a été exécuté avec succès", - "esqlEditor.query.esqlQueriesCopy": "Copier la requête dans le presse-papier", - "esqlEditor.query.esqlQueriesListRun": "Exécuter la requête", "esqlEditor.query.querieshistoryTable": "Tableau d'historique des recherches", "esqlEditor.query.recentQueriesColumnLabel": "Recherches récentes", "esqlEditor.query.refreshLabel": "Actualiser", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 04bc03184b777..c61887e9f0a2d 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -3139,6 +3139,8 @@ "esqlEditor.query.EnableWordWrapLabel": "パイプの改行を追加", "esqlEditor.query.errorCount": "{count} {count, plural, other {# 件のエラー}}", "esqlEditor.query.errorsTitle": "エラー", + "esqlEditor.query.esqlQueriesCopy": "クエリをクリップボードにコピー", + "esqlEditor.query.esqlQueriesListRun": "クエリーを実行", "esqlEditor.query.expandLabel": "拡張", "esqlEditor.query.feedback": "フィードバック", "esqlEditor.query.hideQueriesLabel": "最近のクエリーを非表示", @@ -3148,8 +3150,6 @@ "esqlEditor.query.lineNumber": "行{lineNumber}", "esqlEditor.query.querieshistory.error": "クエリ失敗", "esqlEditor.query.querieshistory.success": "クエリは正常に実行されました", - "esqlEditor.query.esqlQueriesCopy": "クエリをクリップボードにコピー", - "esqlEditor.query.esqlQueriesListRun": "クエリーを実行", "esqlEditor.query.querieshistoryTable": "クエリ履歴テーブル", "esqlEditor.query.recentQueriesColumnLabel": "最近のクエリー", "esqlEditor.query.refreshLabel": "更新", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 1d48e398dfd0c..cade72b5e7a0c 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -3095,6 +3095,8 @@ "esqlEditor.query.EnableWordWrapLabel": "在管道符上添加换行符", "esqlEditor.query.errorCount": "{count} 个{count, plural, other {错误}}", "esqlEditor.query.errorsTitle": "错误", + "esqlEditor.query.esqlQueriesCopy": "复制查询到剪贴板", + "esqlEditor.query.esqlQueriesListRun": "运行查询", "esqlEditor.query.expandLabel": "展开", "esqlEditor.query.feedback": "反馈", "esqlEditor.query.hideQueriesLabel": "隐藏最近查询", @@ -3104,8 +3106,6 @@ "esqlEditor.query.lineNumber": "第 {lineNumber} 行", "esqlEditor.query.querieshistory.error": "查询失败", "esqlEditor.query.querieshistory.success": "已成功运行查询", - "esqlEditor.query.esqlQueriesCopy": "复制查询到剪贴板", - "esqlEditor.query.esqlQueriesListRun": "运行查询", "esqlEditor.query.querieshistoryTable": "查询历史记录表", "esqlEditor.query.recentQueriesColumnLabel": "最近查询", "esqlEditor.query.refreshLabel": "刷新",