From 077d743e87d18e89ecd1b6a7920c63bc6f425c88 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 16 Sep 2024 18:03:23 -0700 Subject: [PATCH 01/20] Add properties and schema for new advanced monitoring settings --- .../fleet/common/types/models/agent_policy.ts | 38 +++++++++++++++++++ .../fleet/server/saved_objects/index.ts | 15 ++++++++ .../fleet/server/services/agent_policy.ts | 3 ++ .../fleet/server/types/models/agent_policy.ts | 26 +++++++++++++ 4 files changed, 82 insertions(+) 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 e639b364343d9..a249219f94f92 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -44,6 +44,24 @@ export interface NewAgentPolicy { keep_monitoring_alive?: boolean | null; supports_agentless?: boolean | null; global_data_tags?: GlobalDataTag[]; + monitoring_pprof_enabled?: boolean; + monitoring_http?: { + enabled: boolean; + host: string; + port: number; + buffer: { enabled: boolean }; + }; + monitoring_diagnostics?: { + limit: { + interval: string | null; + burst: number | null; + }; + uploader: { + max_retries: number | null; + init_dur: string | null; + max_dur: string | null; + }; + }; } export interface GlobalDataTag { @@ -119,6 +137,26 @@ export interface FullAgentPolicyMonitoring { metrics: boolean; logs: boolean; traces: boolean; + pprof?: { + enabled: boolean; + }; + http?: { + enabled: boolean; + host: string; + port: number; + buffer: { enabled: boolean }; + }; + diagnostics?: { + limit?: { + interval?: string | null; + burst?: number | null; + }; + uploader?: { + max_retries?: number | null; + init_dur?: string | null; + max_dur?: string | null; + }; + }; } export interface FullAgentPolicy { diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index 3c224ee6ba881..b0f1e179a47c9 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -223,6 +223,9 @@ export const getSavedObjectTypes = ( advanced_settings: { type: 'flattened', index: false }, supports_agentless: { type: 'boolean' }, global_data_tags: { type: 'flattened', index: false }, + monitoring_pprof_enabled: { type: 'boolean', index: false }, + monitoring_http: { type: 'flattened', index: false }, + monitoring_diagnostics: { type: 'flattened', index: false }, }, }, migrations: { @@ -263,6 +266,18 @@ export const getSavedObjectTypes = ( }, ], }, + '4': { + changes: [ + { + type: 'mappings_addition', + addedMappings: { + monitoring_pprof_enabled: { type: 'boolean', index: false }, + monitoring_http: { type: 'flattened', index: false }, + monitoring_diagnostics: { type: 'flattened', index: false }, + }, + }, + ], + }, }, }, [AGENT_POLICY_SAVED_OBJECT_TYPE]: { diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index 999448f7cae47..dc856820695a2 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -759,6 +759,9 @@ class AgentPolicyService { 'fleet_server_host_id', 'supports_agentless', 'global_data_tags', + 'monitoring_pprof_enabled', + 'monitoring_http', + 'monitoring_diagnostics', ]), ...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 560f6939eedba..0b751b456fcfa 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -102,6 +102,32 @@ export const AgentPolicyBaseSchema = { } ) ), + monitoring_pprof_enabled: schema.maybe(schema.boolean()), + monitoring_http: schema.maybe( + schema.object({ + enabled: schema.boolean(), + host: schema.string({ defaultValue: 'localhost' }), + port: schema.number({ min: 0, max: 65353, defaultValue: 6791 }), + buffer: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), + }) + ), + monitoring_diagnostics: schema.maybe( + schema.object({ + limit: schema.maybe( + schema.object({ + interval: schema.maybe(schema.nullable(schema.string())), + burst: schema.maybe(schema.nullable(schema.number())), + }) + ), + uploader: schema.maybe( + schema.object({ + max_retries: schema.maybe(schema.nullable(schema.number())), + init_dur: schema.maybe(schema.nullable(schema.string())), + max_dur: schema.maybe(schema.nullable(schema.string())), + }) + ), + }) + ), }; function validateGlobalDataTagInput(tags: GlobalDataTag[]): string | undefined { From 0777f901ffc6f4dcc21ca431eb2467c021820068 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 16 Sep 2024 18:04:22 -0700 Subject: [PATCH 02/20] Add monitoring properties to openapi spec --- .../plugins/fleet/common/openapi/bundled.json | 161 ++++++++++++++++++ .../plugins/fleet/common/openapi/bundled.yaml | 106 ++++++++++++ .../components/schemas/agent_policy.yaml | 44 +++++ .../components/schemas/full_agent_policy.yaml | 62 +++++++ 4 files changed, 373 insertions(+) diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index aeef4ba323fa9..192111bd578d2 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -7592,6 +7592,72 @@ }, "description": "User defined data tags that are added to all of the inputs. The values can be strings or numbers." } + }, + "monitoring_pprof_enabled": { + "type": "boolean" + }, + "monitoring_http": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "host": { + "type": "string" + }, + "port": { + "type": "number" + }, + "buffer": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + }, + "required": [ + "enabled" + ] + } + }, + "required": [ + "enabled" + ] + }, + "monitoring_diagnostics": { + "type": "object", + "properties": { + "limit": { + "type": "object", + "properties": { + "interval": { + "type": "string", + "nullable": true + }, + "burst": { + "type": "number", + "nullable": true + } + } + }, + "uploader": { + "type": "object", + "properties": { + "max_retries": { + "type": "number", + "nullable": true + }, + "init_dur": { + "type": "string", + "nullable": true + }, + "max_dur": { + "type": "string", + "nullable": true + } + } + } + } } }, "required": [ @@ -7874,6 +7940,101 @@ } } }, + "monitoring": { + "type": "object", + "properties": { + "namespace": { + "type": "string" + }, + "use_output": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "metrics": { + "type": "boolean" + }, + "logs": { + "type": "boolean" + }, + "traces": { + "type": "boolean" + }, + "pprof": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + }, + "required": [ + "enabled" + ] + }, + "http": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "host": { + "type": "string" + }, + "port": { + "type": "number" + }, + "buffer": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + } + } + }, + "required": [ + "enabled" + ] + }, + "diagnostics": { + "type": "object", + "properties": { + "limit": { + "type": "object", + "properties": { + "interval": { + "type": "string" + }, + "burst": { + "type": "number" + } + } + }, + "uploader": { + "type": "object", + "properties": { + "max_retries": { + "type": "number" + }, + "init_dur": { + "type": "string" + }, + "max_dur": { + "type": "string" + } + } + } + } + } + }, + "required": [ + "enabled", + "metrics", + "logs", + "traces" + ] + }, "fleet": { "oneOf": [ { diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index d5cb90624a196..e506b2fec0378 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -4861,6 +4861,50 @@ components: description: >- User defined data tags that are added to all of the inputs. The values can be strings or numbers. + monitoring_pprof_enabled: + type: boolean + monitoring_http: + type: object + properties: + enabled: + type: boolean + host: + type: string + port: + type: number + buffer: + type: object + properties: + enabled: + type: boolean + required: + - enabled + required: + - enabled + monitoring_diagnostics: + type: object + properties: + limit: + type: object + properties: + interval: + type: string + nullable: true + burst: + type: number + nullable: true + uploader: + type: object + properties: + max_retries: + type: number + nullable: true + init_dur: + type: string + nullable: true + max_dur: + type: string + nullable: true required: - id - status @@ -5054,6 +5098,68 @@ components: type: integer data: $ref: '#/components/schemas/full_agent_policy_output_permissions' + monitoring: + type: object + properties: + namespace: + type: string + use_output: + type: string + enabled: + type: boolean + metrics: + type: boolean + logs: + type: boolean + traces: + type: boolean + pprof: + type: object + properties: + enabled: + type: boolean + required: + - enabled + http: + type: object + properties: + enabled: + type: boolean + host: + type: string + port: + type: number + buffer: + type: object + properties: + enabled: + type: boolean + required: + - enabled + diagnostics: + type: object + properties: + limit: + type: object + properties: + interval: + type: string + burst: + type: number + uploader: + type: object + properties: + max_retries: + type: number + init_dur: + type: string + max_dur: + type: string + required: + - enabled + - metrics + - logs + - traces fleet: oneOf: - type: object diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml index 02fd5c2800a48..a323c7e9f40f9 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml @@ -87,6 +87,50 @@ properties: - type: string - type: number description: User defined data tags that are added to all of the inputs. The values can be strings or numbers. + monitoring_pprof_enabled: + type: boolean + monitoring_http: + type: object + properties: + enabled: + type: boolean + host: + type: string + port: + type: number + buffer: + type: object + properties: + enabled: + type: boolean + required: + - enabled + required: + - enabled + monitoring_diagnostics: + type: object + properties: + limit: + type: object + properties: + interval: + type: string + nullable: true + burst: + type: number + nullable: true + uploader: + type: object + properties: + max_retries: + type: number + nullable: true + init_dur: + type: string + nullable: true + max_dur: + type: string + nullable: true required: - id - status diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml index afe7f1aec328e..468cf4f43359e 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml @@ -16,6 +16,68 @@ properties: type: integer data: $ref: ./full_agent_policy_output_permissions.yaml + monitoring: + type: object + properties: + namespace: + type: string + use_output: + type: string + enabled: + type: boolean + metrics: + type: boolean + logs: + type: boolean + traces: + type: boolean + pprof: + type: object + properties: + enabled: + type: boolean + required: + - enabled + http: + type: object + properties: + enabled: + type: boolean + host: + type: string + port: + type: number + buffer: + type: object + properties: + enabled: + type: boolean + required: + - enabled + diagnostics: + type: object + properties: + limit: + type: object + properties: + interval: + type: string + burst: + type: number + uploader: + type: object + properties: + max_retries: + type: number + init_dur: + type: string + max_dur: + type: string + required: + - enabled + - metrics + - logs + - traces fleet: oneOf: - type: object From 3ed2baa614e966abc6dc9e5fd6ec68f2632fb2fb Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 16 Sep 2024 21:54:40 -0700 Subject: [PATCH 03/20] Adjust types --- .../fleet/common/types/models/agent_policy.ts | 16 ++++++++-------- .../fleet/server/types/models/agent_policy.ts | 6 +++--- 2 files changed, 11 insertions(+), 11 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 a249219f94f92..ad697ee244942 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -47,16 +47,16 @@ export interface NewAgentPolicy { monitoring_pprof_enabled?: boolean; monitoring_http?: { enabled: boolean; - host: string; - port: number; - buffer: { enabled: boolean }; + host?: string; + port?: number; + buffer?: { enabled: boolean }; }; monitoring_diagnostics?: { - limit: { + limit?: { interval: string | null; burst: number | null; }; - uploader: { + uploader?: { max_retries: number | null; init_dur: string | null; max_dur: string | null; @@ -142,9 +142,9 @@ export interface FullAgentPolicyMonitoring { }; http?: { enabled: boolean; - host: string; - port: number; - buffer: { enabled: boolean }; + host?: string; + port?: number; + buffer?: { enabled: boolean }; }; diagnostics?: { limit?: { 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 0b751b456fcfa..25a9b2c2694e9 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -106,9 +106,9 @@ export const AgentPolicyBaseSchema = { monitoring_http: schema.maybe( schema.object({ enabled: schema.boolean(), - host: schema.string({ defaultValue: 'localhost' }), - port: schema.number({ min: 0, max: 65353, defaultValue: 6791 }), - buffer: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), + host: schema.maybe(schema.string({ defaultValue: 'localhost' })), + port: schema.maybe(schema.number({ min: 0, max: 65353, defaultValue: 6791 })), + buffer: schema.maybe(schema.object({ enabled: schema.boolean({ defaultValue: false }) })), }) ), monitoring_diagnostics: schema.maybe( From 15a34a8ad7e8c06f0ca3446858b1506b9e4599bf Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 16 Sep 2024 21:55:33 -0700 Subject: [PATCH 04/20] Remove advanced setting config for http monitoring, add saved object migration to move them to the new properties --- .../common/settings/agent_policy_settings.tsx | 26 ---- .../fleet/server/saved_objects/index.ts | 2 + .../migrations/to_v8_16_0.test.ts | 134 ++++++++++++++++++ .../saved_objects/migrations/to_v8_16_0.ts | 31 ++++ 4 files changed, 167 insertions(+), 26 deletions(-) create mode 100644 x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts create mode 100644 x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts 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 e1bea2103c636..a4b41979840b2 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.tsx @@ -105,32 +105,6 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ 'https://www.elastic.co/guide/en/fleet/current/elastic-agent-standalone-logging-config.html#elastic-agent-standalone-logging-settings', schema: zodStringWithDurationValidation.default('30s'), }, - { - name: 'agent.monitoring.http', - api_field: { - name: 'agent_monitoring_http', - }, - title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpTitle', { - defaultMessage: 'HTTP monitoring endpoint', - }), - description: i18n.translate( - 'xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpDescription', - { - defaultMessage: - 'Enables a liveness HTTP endpoint that returns the overall health of Elastic Agent. This can be used by Kubernetes to restart the container, for example.', - } - ), - learnMoreLink: - 'https://www.elastic.co/guide/en/fleet/current/agent-policy.html#agent-policy-http-monitoring', - schema: z - .object({ - enabled: z.boolean().describe('Enabled').default(false), - host: z.string().describe('Host').default('localhost'), - port: z.number().describe('Port').min(0).max(65353).default(6791), - 'buffer.enabled': z.boolean().describe('Buffer Enabled').default(false), - }) - .default({}), - }, { name: 'agent.logging.level', title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', { diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index b0f1e179a47c9..eff928d887f5f 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -100,6 +100,7 @@ import { migratePackagePolicyIdsToV8150, migratePackagePolicySetRequiresRootToV8150, } from './migrations/to_v8_15_0'; +import { migrateAgentPolicyToV8160 } from './migrations/to_v8_16_0'; /* * Saved object types and mappings @@ -234,6 +235,7 @@ export const getSavedObjectTypes = ( '8.4.0': migrateAgentPolicyToV840, '8.5.0': migrateAgentPolicyToV850, '8.9.0': migrateAgentPolicyToV890, + '8.16.0': migrateAgentPolicyToV8160, }, modelVersions: { '1': { diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts new file mode 100644 index 0000000000000..7a15b05407cd3 --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts @@ -0,0 +1,134 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObject, SavedObjectMigrationContext } from '@kbn/core-saved-objects-server'; + +import type { AgentPolicy } from '../../../common'; + +import { migrateAgentPolicyToV8160 } from './to_v8_16_0'; + +describe('migrateAgentPolicyToV8160', () => { + it('should migrate advanced_settings.agent_monitoring_http to monitoring_http', () => { + const agentPolicyDoc: SavedObject = { + id: 'policy1', + type: 'ingest-agent-policies', + references: [], + attributes: { + id: 'policy1', + name: 'Policy 1', + namespace: 'default', + advanced_settings: { + agent_monitoring_http: { + enabled: true, + host: 'localhost', + port: 1111, + 'buffer.enabled': true, + }, + }, + is_managed: false, + status: 'active', + updated_at: '2021-08-17T14:00:00.000Z', + updated_by: 'elastic', + revision: 1, + is_protected: false, + }, + }; + + const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + agentPolicyDoc, + {} as SavedObjectMigrationContext + ); + + expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ + enabled: true, + host: 'localhost', + port: 1111, + buffer: { + enabled: true, + }, + }); + expect( + migratedAgentPolicyDoc.attributes.advanced_settings?.agent_monitoring_http + ).toBeUndefined(); + }); + + it('should migrate advanced_settings.agent_monitoring_http to monitoring_http when most values are missing', () => { + const agentPolicyDoc: SavedObject = { + id: 'policy1', + type: 'ingest-agent-policies', + references: [], + attributes: { + id: 'policy1', + name: 'Policy 1', + namespace: 'default', + advanced_settings: { + agent_monitoring_http: { + enabled: true, + }, + }, + is_managed: false, + status: 'active', + updated_at: '2021-08-17T14:00:00.000Z', + updated_by: 'elastic', + revision: 1, + is_protected: false, + }, + }; + + const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + agentPolicyDoc, + {} as SavedObjectMigrationContext + ); + + expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ + enabled: true, + }); + expect( + migratedAgentPolicyDoc.attributes.advanced_settings?.agent_monitoring_http + ).toBeUndefined(); + }); + + it('should migrate advanced_settings.agent_monitoring_http to monitoring_http when some values are missing', () => { + const agentPolicyDoc: SavedObject = { + id: 'policy1', + type: 'ingest-agent-policies', + references: [], + attributes: { + id: 'policy1', + name: 'Policy 1', + namespace: 'default', + advanced_settings: { + agent_monitoring_http: { + enabled: true, + 'buffer.enabled': true, + }, + }, + is_managed: false, + status: 'active', + updated_at: '2021-08-17T14:00:00.000Z', + updated_by: 'elastic', + revision: 1, + is_protected: false, + }, + }; + + const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + agentPolicyDoc, + {} as SavedObjectMigrationContext + ); + + expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ + enabled: true, + buffer: { + enabled: true, + }, + }); + expect( + migratedAgentPolicyDoc.attributes.advanced_settings?.agent_monitoring_http + ).toBeUndefined(); + }); +}); diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts new file mode 100644 index 0000000000000..b0feeb5dc2212 --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectMigrationFn } from '@kbn/core-saved-objects-server'; + +import type { AgentPolicy } from '../../../common'; + +export const migrateAgentPolicyToV8160: SavedObjectMigrationFn = ( + agentPolicyDoc +) => { + const advancedSettings = agentPolicyDoc.attributes.advanced_settings; + if (advancedSettings?.agent_monitoring_http) { + agentPolicyDoc.attributes.monitoring_http = { + enabled: advancedSettings.agent_monitoring_http.enabled, + host: advancedSettings.agent_monitoring_http.host, + port: advancedSettings.agent_monitoring_http.port, + buffer: + advancedSettings.agent_monitoring_http['buffer.enabled'] !== undefined + ? { + enabled: advancedSettings.agent_monitoring_http['buffer.enabled'], + } + : undefined, + }; + delete advancedSettings.agent_monitoring_http; + } + return agentPolicyDoc; +}; From 5c38e983f3f9ec54a1db0d972d8b30e9c70d38e2 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 17 Sep 2024 13:05:52 -0700 Subject: [PATCH 05/20] Remove unnecessary nullability --- .../components/schemas/agent_policy.yaml | 5 ----- .../fleet/common/types/models/agent_policy.ts | 20 +++++++++---------- .../fleet/server/types/models/agent_policy.ts | 10 +++++----- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml index a323c7e9f40f9..72b9f0fd39c8d 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml @@ -115,22 +115,17 @@ properties: properties: interval: type: string - nullable: true burst: type: number - nullable: true uploader: type: object properties: max_retries: type: number - nullable: true init_dur: type: string - nullable: true max_dur: type: string - nullable: true required: - id - status 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 ad697ee244942..23640e3026628 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -53,13 +53,13 @@ export interface NewAgentPolicy { }; monitoring_diagnostics?: { limit?: { - interval: string | null; - burst: number | null; + interval?: string; + burst?: number; }; uploader?: { - max_retries: number | null; - init_dur: string | null; - max_dur: string | null; + max_retries?: number; + init_dur?: string; + max_dur?: string; }; }; } @@ -148,13 +148,13 @@ export interface FullAgentPolicyMonitoring { }; diagnostics?: { limit?: { - interval?: string | null; - burst?: number | null; + interval?: string; + burst?: number; }; uploader?: { - max_retries?: number | null; - init_dur?: string | null; - max_dur?: string | null; + max_retries?: number; + init_dur?: string; + max_dur?: string; }; }; } 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 25a9b2c2694e9..38441b06eabbf 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -115,15 +115,15 @@ export const AgentPolicyBaseSchema = { schema.object({ limit: schema.maybe( schema.object({ - interval: schema.maybe(schema.nullable(schema.string())), - burst: schema.maybe(schema.nullable(schema.number())), + interval: schema.maybe(schema.string()), + burst: schema.maybe(schema.number()), }) ), uploader: schema.maybe( schema.object({ - max_retries: schema.maybe(schema.nullable(schema.number())), - init_dur: schema.maybe(schema.nullable(schema.string())), - max_dur: schema.maybe(schema.nullable(schema.string())), + max_retries: schema.maybe(schema.number()), + init_dur: schema.maybe(schema.string()), + max_dur: schema.maybe(schema.string()), }) ), }) From 9065613433cd4d1b02b83b8c576e3e4746a4a757 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 17 Sep 2024 13:07:52 -0700 Subject: [PATCH 06/20] Compile monitoring settings to agent yaml --- .../agent_policies/full_agent_policy.test.ts | 141 ++++++++++++++++++ .../agent_policies/full_agent_policy.ts | 127 ++++++++++++---- 2 files changed, 236 insertions(+), 32 deletions(-) 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 d2ff49b04e340..1219803f51dab 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 @@ -20,6 +20,7 @@ import { getPackageInfo } from '../epm/packages'; import { generateFleetConfig, getFullAgentPolicy, + getFullMonitoringSettings, transformOutputToFullPolicyOutput, } from './full_agent_policy'; import { getMonitoringPermissions } from './monitoring_permissions'; @@ -901,6 +902,146 @@ describe('getFullAgentPolicy', () => { }); }); +describe('getFullMonitoringSettings', () => { + it('should return the correct settings when all values are present', async () => { + const monitoringSettings = getFullMonitoringSettings( + { + namespace: 'default', + monitoring_enabled: ['metrics', 'logs', 'traces'], + monitoring_pprof_enabled: true, + monitoring_http: { + enabled: true, + host: 'localhost', + port: 1111, + buffer: { enabled: true }, + }, + monitoring_diagnostics: { + limit: { + interval: '1m', + burst: 10, + }, + uploader: { + max_retries: 3, + init_dur: '1m', + max_dur: '10m', + }, + }, + }, + { + id: 'some-output', + is_default: false, + type: 'elasticsearch', + } + ); + + expect(monitoringSettings).toEqual({ + enabled: true, + logs: true, + metrics: true, + traces: true, + namespace: 'default', + use_output: 'some-output', + pprof: { enabled: true }, + http: { + enabled: true, + host: 'localhost', + port: 1111, + buffer: { enabled: true }, + }, + diagnostics: { + limit: { + interval: '1m', + burst: 10, + }, + uploader: { + max_retries: 3, + init_dur: '1m', + max_dur: '10m', + }, + }, + }); + }); + + it('should return the correct settings when some values are present', async () => { + const monitoringSettings = getFullMonitoringSettings( + { + namespace: 'default', + monitoring_enabled: ['metrics'], + monitoring_pprof_enabled: false, + monitoring_http: { + enabled: true, + host: 'localhost', + buffer: { enabled: false }, + }, + monitoring_diagnostics: { + limit: { + interval: '1m', + }, + uploader: { + max_dur: '10m', + }, + }, + }, + { + id: 'some-output', + is_default: true, + type: 'elasticsearch', + } + ); + + expect(monitoringSettings).toEqual({ + enabled: true, + logs: false, + metrics: true, + traces: false, + namespace: 'default', + use_output: 'default', + pprof: { enabled: false }, + http: { + enabled: true, + host: 'localhost', + buffer: { enabled: false }, + }, + diagnostics: { + limit: { + interval: '1m', + }, + uploader: { + max_dur: '10m', + }, + }, + }); + }); + + it('should return the correct settings when beats monitoring is disabled and minimal values are present', async () => { + const monitoringSettings = getFullMonitoringSettings( + { + namespace: 'default', + monitoring_enabled: [], + monitoring_http: { + enabled: true, + }, + monitoring_diagnostics: {}, + }, + { + id: 'some-output', + is_default: true, + type: 'elasticsearch', + } + ); + + expect(monitoringSettings).toEqual({ + enabled: false, + logs: false, + metrics: false, + traces: false, + http: { + enabled: true, + }, + }); + }); +}); + describe('transformOutputToFullPolicyOutput', () => { it('should works with only required field on a output', () => { const policyOutput = 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 d00721f08a3d9..30653f2ef13be 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 @@ -136,36 +136,6 @@ export async function getFullAgentPolicy( const packagePolicySecretReferences = (agentPolicy?.package_policies || []).flatMap( (policy) => policy.secret_references || [] ); - const defaultMonitoringConfig: FullAgentPolicyMonitoring = { - enabled: false, - logs: false, - metrics: false, - traces: false, - }; - - let monitoring: FullAgentPolicyMonitoring = { ...defaultMonitoringConfig }; - - // If the agent policy has monitoring enabled for at least one of "logs", "metrics", or "traces" - // generate a monitoring config for the resulting compiled agent policy - if (agentPolicy.monitoring_enabled && agentPolicy.monitoring_enabled.length > 0) { - monitoring = { - namespace: agentPolicy.namespace, - use_output: getOutputIdForAgentPolicy(monitoringOutput), - enabled: true, - logs: agentPolicy.monitoring_enabled.includes(dataTypes.Logs), - metrics: agentPolicy.monitoring_enabled.includes(dataTypes.Metrics), - traces: agentPolicy.monitoring_enabled.includes(dataTypes.Traces), - }; - // If the `keep_monitoring_alive` flag is set, enable monitoring but don't enable logs or metrics. - // This allows cloud or other environments to keep the monitoring server alive without tearing it down. - } else if (agentPolicy.keep_monitoring_alive) { - monitoring = { - enabled: true, - logs: false, - metrics: false, - traces: false, - }; - } const fullAgentPolicy: FullAgentPolicy = { id: agentPolicy.id, @@ -188,7 +158,7 @@ export async function getFullAgentPolicy( sourceURI: downloadSourceUri, ...(downloadSourceProxyUri ? { proxy_url: downloadSourceProxyUri } : {}), }, - monitoring, + monitoring: getFullMonitoringSettings(agentPolicy, monitoringOutput), features, protection: { enabled: agentPolicy.is_protected, @@ -550,11 +520,104 @@ export function transformOutputToFullPolicyOutput( return newOutput; } +export function getFullMonitoringSettings( + agentPolicy: Pick< + AgentPolicy, + | 'namespace' + | 'monitoring_enabled' + | 'keep_monitoring_alive' + | 'monitoring_pprof_enabled' + | 'monitoring_http' + | 'monitoring_diagnostics' + >, + monitoringOutput: Pick +): FullAgentPolicyMonitoring { + // Set base beats monitoring settings + const monitoring: FullAgentPolicyMonitoring = { + enabled: Boolean( + (agentPolicy.monitoring_enabled && agentPolicy.monitoring_enabled.length > 0) || + agentPolicy.keep_monitoring_alive + ), + logs: false, + metrics: false, + traces: false, + }; + + // If the agent policy has monitoring enabled for at least one of "logs", "metrics", or "traces" + // generate a monitoring config for the resulting compiled agent policy + if (agentPolicy.monitoring_enabled && agentPolicy.monitoring_enabled.length > 0) { + monitoring.namespace = agentPolicy.namespace; + monitoring.use_output = getOutputIdForAgentPolicy(monitoringOutput); + monitoring.logs = agentPolicy.monitoring_enabled.includes(dataTypes.Logs); + monitoring.metrics = agentPolicy.monitoring_enabled.includes(dataTypes.Metrics); + monitoring.traces = agentPolicy.monitoring_enabled.includes(dataTypes.Traces); + } + + if (agentPolicy.monitoring_pprof_enabled !== undefined) { + monitoring.pprof = { + enabled: agentPolicy.monitoring_pprof_enabled, + }; + } + + // Conditionally set http monitoring settings + if (agentPolicy.monitoring_http?.enabled) { + monitoring.http = { + enabled: agentPolicy.monitoring_http.enabled, + ...(agentPolicy.monitoring_http.host && { host: agentPolicy.monitoring_http.host }), + ...(agentPolicy.monitoring_http.port && { port: agentPolicy.monitoring_http.port }), + ...(agentPolicy.monitoring_http.buffer && { + buffer: { enabled: agentPolicy.monitoring_http.buffer.enabled }, + }), + }; + } + + // Conditionally set diagnostics monitoring settings + if (agentPolicy.monitoring_diagnostics?.limit || agentPolicy.monitoring_diagnostics?.uploader) { + monitoring.diagnostics = {}; + + if ( + agentPolicy.monitoring_diagnostics.limit && + (agentPolicy.monitoring_diagnostics.limit.interval || + typeof agentPolicy.monitoring_diagnostics.limit.burst === 'number') + ) { + monitoring.diagnostics.limit = { + ...(agentPolicy.monitoring_diagnostics.limit.interval && { + interval: agentPolicy.monitoring_diagnostics.limit.interval, + }), + ...(typeof agentPolicy.monitoring_diagnostics.limit.burst === 'number' && { + burst: agentPolicy.monitoring_diagnostics.limit.burst, + }), + }; + } + + if ( + agentPolicy.monitoring_diagnostics.uploader && + (typeof agentPolicy.monitoring_diagnostics.uploader.max_retries === 'number' || + agentPolicy.monitoring_diagnostics.uploader.init_dur || + agentPolicy.monitoring_diagnostics.uploader.max_dur) + ) { + monitoring.diagnostics.uploader = { + ...(typeof agentPolicy.monitoring_diagnostics.uploader.max_retries === 'number' && { + max_retries: agentPolicy.monitoring_diagnostics.uploader.max_retries, + }), + ...(agentPolicy.monitoring_diagnostics.uploader.init_dur && { + init_dur: agentPolicy.monitoring_diagnostics.uploader.init_dur, + }), + ...(agentPolicy.monitoring_diagnostics.uploader.max_dur && { + max_dur: agentPolicy.monitoring_diagnostics.uploader.max_dur, + }), + }; + } + } + + return monitoring; +} + /** * Get id used in full agent policy (sent to the agents) * we use "default" for the default policy to avoid breaking changes */ -function getOutputIdForAgentPolicy(output: Output) { +function getOutputIdForAgentPolicy(output: Pick) { if (output.is_default && output.type === outputType.Elasticsearch) { return DEFAULT_OUTPUT.name; } From 402906864be8a4c19b82bbe15dc6f9e274975415 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 17 Sep 2024 17:23:42 -0700 Subject: [PATCH 07/20] Move migration to model version --- .../fleet/server/saved_objects/index.ts | 9 ++++++--- .../agent_policy_v4.test.ts} | 19 +++++++++++-------- .../agent_policy_v4.ts} | 4 ++-- .../model_versions/{v1.ts => settings_v1.ts} | 0 4 files changed, 19 insertions(+), 13 deletions(-) rename x-pack/plugins/fleet/server/saved_objects/{migrations/to_v8_16_0.test.ts => model_versions/agent_policy_v4.test.ts} (86%) rename x-pack/plugins/fleet/server/saved_objects/{migrations/to_v8_16_0.ts => model_versions/agent_policy_v4.ts} (84%) rename x-pack/plugins/fleet/server/saved_objects/model_versions/{v1.ts => settings_v1.ts} (100%) diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index eff928d887f5f..0eb6c86df01e2 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -91,7 +91,7 @@ import { migratePackagePolicyToV81102, migratePackagePolicyEvictionsFromV81102, } from './migrations/security_solution/to_v8_11_0_2'; -import { settingsV1 } from './model_versions/v1'; +import { settingsV1 } from './model_versions/settings_v1'; import { packagePolicyV13AdvancedFields, packagePolicyV10OnWriteScanFix, @@ -100,7 +100,7 @@ import { migratePackagePolicyIdsToV8150, migratePackagePolicySetRequiresRootToV8150, } from './migrations/to_v8_15_0'; -import { migrateAgentPolicyToV8160 } from './migrations/to_v8_16_0'; +import { backfillAgentPolicyToV4 } from './model_versions/agent_policy_v4'; /* * Saved object types and mappings @@ -235,7 +235,6 @@ export const getSavedObjectTypes = ( '8.4.0': migrateAgentPolicyToV840, '8.5.0': migrateAgentPolicyToV850, '8.9.0': migrateAgentPolicyToV890, - '8.16.0': migrateAgentPolicyToV8160, }, modelVersions: { '1': { @@ -278,6 +277,10 @@ export const getSavedObjectTypes = ( monitoring_diagnostics: { type: 'flattened', index: false }, }, }, + { + type: 'data_backfill', + backfillFn: backfillAgentPolicyToV4, + }, ], }, }, diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.test.ts similarity index 86% rename from x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts rename to x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.test.ts index 7a15b05407cd3..3bf91ccacb46e 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.test.ts +++ b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.test.ts @@ -5,11 +5,14 @@ * 2.0. */ -import type { SavedObject, SavedObjectMigrationContext } from '@kbn/core-saved-objects-server'; +import type { + SavedObject, + SavedObjectModelTransformationContext, +} from '@kbn/core-saved-objects-server'; import type { AgentPolicy } from '../../../common'; -import { migrateAgentPolicyToV8160 } from './to_v8_16_0'; +import { backfillAgentPolicyToV4 } from './agent_policy_v4'; describe('migrateAgentPolicyToV8160', () => { it('should migrate advanced_settings.agent_monitoring_http to monitoring_http', () => { @@ -38,9 +41,9 @@ describe('migrateAgentPolicyToV8160', () => { }, }; - const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + const migratedAgentPolicyDoc = backfillAgentPolicyToV4( agentPolicyDoc, - {} as SavedObjectMigrationContext + {} as SavedObjectModelTransformationContext ); expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ @@ -79,9 +82,9 @@ describe('migrateAgentPolicyToV8160', () => { }, }; - const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + const migratedAgentPolicyDoc = backfillAgentPolicyToV4( agentPolicyDoc, - {} as SavedObjectMigrationContext + {} as SavedObjectModelTransformationContext ); expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ @@ -116,9 +119,9 @@ describe('migrateAgentPolicyToV8160', () => { }, }; - const migratedAgentPolicyDoc = migrateAgentPolicyToV8160( + const migratedAgentPolicyDoc = backfillAgentPolicyToV4( agentPolicyDoc, - {} as SavedObjectMigrationContext + {} as SavedObjectModelTransformationContext ); expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts similarity index 84% rename from x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts rename to x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts index b0feeb5dc2212..fbdaba60061b1 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v8_16_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts @@ -5,11 +5,11 @@ * 2.0. */ -import type { SavedObjectMigrationFn } from '@kbn/core-saved-objects-server'; +import type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server'; import type { AgentPolicy } from '../../../common'; -export const migrateAgentPolicyToV8160: SavedObjectMigrationFn = ( +export const backfillAgentPolicyToV4: SavedObjectModelDataBackfillFn = ( agentPolicyDoc ) => { const advancedSettings = agentPolicyDoc.attributes.advanced_settings; diff --git a/x-pack/plugins/fleet/server/saved_objects/model_versions/v1.ts b/x-pack/plugins/fleet/server/saved_objects/model_versions/settings_v1.ts similarity index 100% rename from x-pack/plugins/fleet/server/saved_objects/model_versions/v1.ts rename to x-pack/plugins/fleet/server/saved_objects/model_versions/settings_v1.ts From 6757c0140a72a1f7f664707e994739ff1e9ade2c Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 17 Sep 2024 20:52:37 -0700 Subject: [PATCH 08/20] Add UI for http monitoring endpoint options --- packages/kbn-doc-links/src/get_doc_links.ts | 1 + packages/kbn-doc-links/src/types.ts | 1 + .../advanced_monitoring.tsx | 283 ++++++++++++++++++ .../agent_policy_advanced_fields/index.tsx | 14 + .../agent_policy_validation.test.tsx | 48 ++- .../components/agent_policy_validation.tsx | 23 ++ .../components/settings/index.tsx | 3 + 7 files changed, 370 insertions(+), 3 deletions(-) create mode 100644 x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index 3ad5d271bde47..365211b254296 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -879,6 +879,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D roleAndPrivileges: `${FLEET_DOCS}fleet-roles-and-privileges.html`, proxiesSettings: `${FLEET_DOCS}fleet-agent-proxy-support.html`, unprivilegedMode: `${FLEET_DOCS}elastic-agent-unprivileged.html#unprivileged-change-mode`, + httpMonitoring: `${FLEET_DOCS}elastic-agent-monitoring-configuration.html`, }, integrationDeveloper: { upload: `${INTEGRATIONS_DEV_DOCS}upload-a-new-integration.html`, diff --git a/packages/kbn-doc-links/src/types.ts b/packages/kbn-doc-links/src/types.ts index cbf085623c3a6..9870d3687e8b2 100644 --- a/packages/kbn-doc-links/src/types.ts +++ b/packages/kbn-doc-links/src/types.ts @@ -564,6 +564,7 @@ export interface DocLinks { roleAndPrivileges: string; proxiesSettings: string; unprivilegedMode: string; + httpMonitoring: string; }>; readonly integrationDeveloper: { upload: string; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx new file mode 100644 index 0000000000000..54137afb6fc24 --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx @@ -0,0 +1,283 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React from 'react'; +import { + EuiDescribedFormGroup, + EuiSpacer, + EuiIconTip, + EuiCheckbox, + EuiLink, + EuiAccordion, + EuiCode, + EuiFlexGroup, + EuiFlexItem, + EuiFormRow, + EuiFieldText, + EuiFieldNumber, +} from '@elastic/eui'; +import styled from 'styled-components'; +import { FormattedMessage } from '@kbn/i18n-react'; + +import type { NewAgentPolicy, AgentPolicy } from '../../../../types'; +import { useStartServices } from '../../../../hooks'; +import type { ValidationResults } from '../agent_policy_validation'; + +const StyledEuiAccordion = styled(EuiAccordion)` + margin-block-start: ${(props) => props.theme.eui.euiSizeS}; + .ingest-active-button { + color: ${(props) => props.theme.eui.euiColorPrimary}; + } +`; + +const PushedDescribedFormGroup = styled(EuiDescribedFormGroup)` + h3, + .euiDescribedFormGroup__description { + padding-left: ${(props) => props.theme.eui.euiSizeL}; + } +`; + +export const AgentPolicyAdvancedMonitoringOptions: React.FunctionComponent<{ + agentPolicy: Partial; + disabled: boolean; + validation: ValidationResults; + touchedFields: { [key: string]: boolean }; + updateTouchedFields: (fields: { [key: string]: boolean }) => void; + updateAgentPolicy: (u: Partial) => void; +}> = ({ + agentPolicy, + disabled, + validation, + touchedFields, + updateTouchedFields, + updateAgentPolicy, +}) => { + const { docLinks } = useStartServices(); + + return ( + + } + buttonClassName={disabled ? undefined : 'ingest-active-button'} + isDisabled={disabled === true} + > + + + + + } + description={ + + + + ), + }} + /> + } + > + {/* Enable base HTTP monitoring endpoint */} + /liveness, + }} + /> + } + disabled={disabled} + checked={agentPolicy.monitoring_http?.enabled} + onChange={(e) => { + const isEnabled = e.target.checked; + const host = isEnabled && !agentPolicy.monitoring_http?.host ? 'localhost' : undefined; + const port = isEnabled && !agentPolicy.monitoring_http?.port ? 6791 : undefined; + updateTouchedFields({ 'monitoring_http.enabled': true }); + updateAgentPolicy({ + monitoring_http: { + ...agentPolicy.monitoring_http, + ...(host ? { host } : {}), + ...(port ? { port } : {}), + enabled: isEnabled, + }, + }); + }} + /> + + + + {/* Host and port */} + + + + } + isDisabled={disabled || !agentPolicy.monitoring_http?.enabled} + error={ + touchedFields['monitoring_http.host'] && validation['monitoring_http.host'] + ? validation['monitoring_http.host'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_http.host'] && validation['monitoring_http.host'] + )} + > + { + updateAgentPolicy({ + monitoring_http: { + ...agentPolicy.monitoring_http!, + host: e.target.value, + }, + }); + }} + onBlur={() => updateTouchedFields({ 'monitoring_http.host': true })} + isInvalid={Boolean( + touchedFields['monitoring_http.host'] && validation['monitoring_http.host'] + )} + /> + + + + + } + isDisabled={disabled || !agentPolicy.monitoring_http?.enabled} + error={ + touchedFields['monitoring_http.port'] && validation['monitoring_http.port'] + ? validation['monitoring_http.port'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_http.port'] && validation['monitoring_http.port'] + )} + > + { + updateAgentPolicy({ + monitoring_http: { + ...agentPolicy.monitoring_http!, + port: e.target.value ? Number(e.target.value) : 0, + }, + }); + }} + onBlur={() => updateTouchedFields({ 'monitoring_http.port': true })} + isInvalid={Boolean( + touchedFields['monitoring_http.port'] && validation['monitoring_http.port'] + )} + /> + + + + + + + {/* Metrics buffer endpoint */} + + /buffer, + }} + />{' '} + + } + /> + + } + disabled={disabled || !agentPolicy.monitoring_http?.enabled} + checked={agentPolicy.monitoring_http?.buffer?.enabled} + onChange={(e) => { + updateTouchedFields({ 'monitoring_http.buffer.enabled': true }); + updateAgentPolicy({ + monitoring_http: { + ...agentPolicy.monitoring_http!, + buffer: { + enabled: e.target.checked, + }, + }, + }); + }} + /> + + + + {/* Profiling endpoint */} + /debug/pprof, + }} + /> + } + disabled={disabled || !agentPolicy.monitoring_http?.enabled} + checked={agentPolicy.monitoring_pprof_enabled} + onChange={(e) => { + updateTouchedFields({ monitoring_pprof_enabled: true }); + updateAgentPolicy({ + monitoring_pprof_enabled: e.target.checked, + }); + }} + /> + + + ); +}; 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 9e35dc441fa28..fc16d56107ccd 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 @@ -62,6 +62,7 @@ import { import { CustomFields } from './custom_fields'; import { SpaceSelector } from './space_selector'; +import { AgentPolicyAdvancedMonitoringOptions } from './advanced_monitoring'; interface Props { agentPolicy: Partial; @@ -141,6 +142,7 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = /> } > + @@ -401,6 +403,7 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = /> } > + = }} /> + + setTouchedFields({ ...touchedFields, ...fields })} + updateAgentPolicy={updateAgentPolicy} + /> + + {AgentTamperProtectionSection} { it('should return error when agentPolicy has empty namespace', () => { const result = agentPolicyFormValidation({ - namespace: 'Default', + namespace: '', name: 'policy', }); expect(result.namespace).toBeDefined(); @@ -33,18 +33,60 @@ describe('Agent Policy form validation', () => { it('should return error when agentPolicy has negative unenroll timeout', () => { const result = agentPolicyFormValidation({ - namespace: 'Default', + namespace: 'default', name: 'policy', unenroll_timeout: -1, }); expect(result.unenroll_timeout).toBeDefined(); }); + it('should return error when agentPolicy has negative inactivity timeout', () => { const result = agentPolicyFormValidation({ - namespace: 'Default', + namespace: 'default', name: 'policy', inactivity_timeout: -1, }); expect(result.inactivity_timeout).toBeDefined(); }); + + it('should return error when agentPolicy has http monitoring enabled without host or port', () => { + expect( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_http: { + enabled: true, + host: 'localhost', + port: 123, + }, + }) + ).toEqual({}); + + expect( + Object.keys( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_http: { + enabled: true, + host: '', + port: 123, + }, + }) + ) + ).toEqual(['monitoring_http.host']); + + expect( + Object.keys( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_http: { + enabled: true, + host: '', + }, + }) + ) + ).toEqual(['monitoring_http.host', 'monitoring_http.port']); + }); }); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx index a52c2b488139c..45374992aeaee 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx @@ -56,5 +56,28 @@ export const agentPolicyFormValidation = ( ]; } + if (agentPolicy.monitoring_http?.enabled) { + if (!agentPolicy.monitoring_http.host?.trim()) { + errors['monitoring_http.host'] = [ + , + ]; + } + + if ( + !agentPolicy.monitoring_http.port || + (agentPolicy.monitoring_http.port !== undefined && agentPolicy.monitoring_http.port <= 0) + ) { + errors['monitoring_http.port'] = [ + , + ]; + } + } + return errors; }; 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 9be265a6385cb..14dcf6df21b9f 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 @@ -57,6 +57,9 @@ const pickAgentPolicyKeysToSend = (agentPolicy: AgentPolicy) => 'is_protected', 'advanced_settings', 'global_data_tags', + 'monitoring_pprof_enabled', + 'monitoring_http', + 'monitoring_diagnostics', ]); const FormWrapper = styled.div` From 953b8dfc44a6b5e4c84035d5d7bd7b969c3291df Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 17 Sep 2024 21:24:18 -0700 Subject: [PATCH 09/20] Add UI for diagnostics options --- .../advanced_monitoring.tsx | 298 +++++++++++++++++- 1 file changed, 296 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx index 54137afb6fc24..1772323d51760 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx @@ -70,6 +70,8 @@ export const AgentPolicyAdvancedMonitoringOptions: React.FunctionComponent<{ isDisabled={disabled === true} > + + {/* HTTP monitoring endpoint */} } > + + {/* Enable base HTTP monitoring endpoint */} } @@ -175,7 +179,7 @@ export const AgentPolicyAdvancedMonitoringOptions: React.FunctionComponent<{ fullWidth label={ } @@ -278,6 +282,296 @@ export const AgentPolicyAdvancedMonitoringOptions: React.FunctionComponent<{ }} /> + + {/* Diagnostics rate limiting */} + + + + } + description={ + + + + ), + }} + /> + } + > + + + + } + isDisabled={disabled} + error={ + touchedFields['monitoring_diagnostics.limit.interval'] && + validation['monitoring_diagnostics.limit.interval'] + ? validation['monitoring_diagnostics.limit.interval'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.limit.interval'] && + validation['monitoring_diagnostics.limit.interval'] + )} + > + { + updateAgentPolicy({ + monitoring_diagnostics: { + ...agentPolicy.monitoring_diagnostics, + limit: { + ...agentPolicy.monitoring_diagnostics?.limit, + interval: e.target.value ? e.target.value : undefined, + }, + }, + }); + }} + onBlur={() => + updateTouchedFields({ 'monitoring_diagnostics.limit.interval': true }) + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.limit.interval'] && + validation['monitoring_diagnostics.limit.interval'] + )} + /> + + + + + } + isDisabled={disabled} + error={ + touchedFields['monitoring_diagnostics.limit.burst'] && + validation['monitoring_diagnostics.limit.burst'] + ? validation['monitoring_diagnostics.limit.burst'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.limit.burst'] && + validation['monitoring_diagnostics.limit.burst'] + )} + > + { + updateAgentPolicy({ + monitoring_diagnostics: { + ...agentPolicy.monitoring_diagnostics, + limit: { + ...agentPolicy.monitoring_diagnostics?.limit, + burst: e.target.value ? Number(e.target.value) : undefined, + }, + }, + }); + }} + onBlur={() => updateTouchedFields({ 'monitoring_diagnostics.limit.burst': true })} + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.limit.burst'] && + validation['monitoring_diagnostics.limit.burst'] + )} + /> + + + {/* Empty to match colums with upload fields below */} + + + + {/* Diagnostics file upload */} + + + + } + description={ + + + + ), + }} + /> + } + > + + + + } + isDisabled={disabled} + error={ + touchedFields['monitoring_diagnostics.uploader.max_retries'] && + validation['monitoring_diagnostics.uploader.max_retries'] + ? validation['monitoring_diagnostics.uploader.max_retries'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.max_retries'] && + validation['monitoring_diagnostics.uploader.max_retries'] + )} + > + { + updateAgentPolicy({ + monitoring_diagnostics: { + ...agentPolicy.monitoring_diagnostics, + uploader: { + ...agentPolicy.monitoring_diagnostics?.uploader, + max_retries: e.target.value ? Number(e.target.value) : undefined, + }, + }, + }); + }} + onBlur={() => + updateTouchedFields({ 'monitoring_diagnostics.uploader.max_retries': true }) + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.max_retries'] && + validation['monitoring_diagnostics.uploader.max_retries'] + )} + /> + + + + + } + isDisabled={disabled} + error={ + touchedFields['monitoring_diagnostics.uploader.init_dur'] && + validation['monitoring_diagnostics.uploader.init_dur'] + ? validation['monitoring_diagnostics.uploader.init_dur'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.init_dur'] && + validation['monitoring_diagnostics.uploader.init_dur'] + )} + > + { + updateAgentPolicy({ + monitoring_diagnostics: { + ...agentPolicy.monitoring_diagnostics, + uploader: { + ...agentPolicy.monitoring_diagnostics?.uploader, + init_dur: e.target.value ? e.target.value : undefined, + }, + }, + }); + }} + onBlur={() => + updateTouchedFields({ 'monitoring_diagnostics.uploader.init_dur': true }) + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.init_dur'] && + validation['monitoring_diagnostics.uploader.init_dur'] + )} + /> + + + + + } + isDisabled={disabled} + error={ + touchedFields['monitoring_diagnostics.uploader.max_dur'] && + validation['monitoring_diagnostics.uploader.max_dur'] + ? validation['monitoring_diagnostics.uploader.max_dur'] + : null + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.max_dur'] && + validation['monitoring_diagnostics.uploader.max_dur'] + )} + > + { + updateAgentPolicy({ + monitoring_diagnostics: { + ...agentPolicy.monitoring_diagnostics, + uploader: { + ...agentPolicy.monitoring_diagnostics?.uploader, + max_dur: e.target.value ? e.target.value : undefined, + }, + }, + }); + }} + onBlur={() => + updateTouchedFields({ 'monitoring_diagnostics.uploader.max_dur': true }) + } + isInvalid={Boolean( + touchedFields['monitoring_diagnostics.uploader.max_dur'] && + validation['monitoring_diagnostics.uploader.max_dur'] + )} + /> + + + + ); }; From 573ee39899803a5fca9da4822d82fadce01a3b4c Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 18 Sep 2024 12:43:21 -0700 Subject: [PATCH 10/20] Enable base monitoring if http monitoring is enabled --- .../agent_policies/full_agent_policy.test.ts | 27 ++++++++++++++++++- .../agent_policies/full_agent_policy.ts | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) 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 1219803f51dab..d0cd350ee0894 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 @@ -1031,7 +1031,7 @@ describe('getFullMonitoringSettings', () => { ); expect(monitoringSettings).toEqual({ - enabled: false, + enabled: true, logs: false, metrics: false, traces: false, @@ -1040,6 +1040,31 @@ describe('getFullMonitoringSettings', () => { }, }); }); + + it('should disable monitoring if beats and http monitoring are disabled', async () => { + const monitoringSettings = getFullMonitoringSettings( + { + namespace: 'default', + monitoring_enabled: [], + monitoring_http: { + enabled: false, + }, + monitoring_diagnostics: {}, + }, + { + id: 'some-output', + is_default: true, + type: 'elasticsearch', + } + ); + + expect(monitoringSettings).toEqual({ + enabled: false, + logs: false, + metrics: false, + traces: false, + }); + }); }); 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 30653f2ef13be..c9d8028e35664 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 @@ -536,6 +536,7 @@ export function getFullMonitoringSettings( const monitoring: FullAgentPolicyMonitoring = { enabled: Boolean( (agentPolicy.monitoring_enabled && agentPolicy.monitoring_enabled.length > 0) || + agentPolicy.monitoring_http?.enabled || agentPolicy.keep_monitoring_alive ), logs: false, From bdf096eeba027142ca2a23387e2c3adba9fd6a11 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 18 Sep 2024 13:52:44 -0700 Subject: [PATCH 11/20] Add validation for diagnostics integer fields --- .../agent_policy_validation.test.tsx | 53 +++++++++++++++++++ .../components/agent_policy_validation.tsx | 28 +++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.test.tsx index 9a64cca34fa9d..e762845d99ef9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.test.tsx @@ -62,6 +62,17 @@ describe('Agent Policy form validation', () => { }) ).toEqual({}); + expect( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_http: { + enabled: false, + host: '', + }, + }) + ).toEqual({}); + expect( Object.keys( agentPolicyFormValidation({ @@ -89,4 +100,46 @@ describe('Agent Policy form validation', () => { ) ).toEqual(['monitoring_http.host', 'monitoring_http.port']); }); + + it('should return error when agentPolicy has invalid diagnostics options', () => { + expect( + Object.keys( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_diagnostics: { + limit: { + burst: 0, + }, + uploader: { + max_retries: -1, + }, + }, + }) + ) + ).toEqual([ + 'monitoring_diagnostics.limit.burst', + 'monitoring_diagnostics.uploader.max_retries', + ]); + + expect( + Object.keys( + agentPolicyFormValidation({ + namespace: 'default', + name: 'policy', + monitoring_diagnostics: { + limit: { + burst: -1, + }, + uploader: { + max_retries: 0, + }, + }, + }) + ) + ).toEqual([ + 'monitoring_diagnostics.limit.burst', + 'monitoring_diagnostics.uploader.max_retries', + ]); + }); }); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx index 45374992aeaee..109e62b0e0de4 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_validation.tsx @@ -42,7 +42,7 @@ export const agentPolicyFormValidation = ( errors.unenroll_timeout = [ , ]; } @@ -51,7 +51,7 @@ export const agentPolicyFormValidation = ( errors.inactivity_timeout = [ , ]; } @@ -79,5 +79,29 @@ export const agentPolicyFormValidation = ( } } + if ( + agentPolicy.monitoring_diagnostics?.limit?.burst !== undefined && + agentPolicy.monitoring_diagnostics?.limit?.burst <= 0 + ) { + errors['monitoring_diagnostics.limit.burst'] = [ + , + ]; + } + + if ( + agentPolicy.monitoring_diagnostics?.uploader?.max_retries !== undefined && + agentPolicy.monitoring_diagnostics?.uploader?.max_retries <= 0 + ) { + errors['monitoring_diagnostics.uploader.max_retries'] = [ + , + ]; + } + return errors; }; From 4eb086e24ab81c7407d505d3cb767b7cbe2bf4c4 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 18 Sep 2024 13:59:55 -0700 Subject: [PATCH 12/20] Fix i18n --- x-pack/plugins/translations/translations/fr-FR.json | 2 -- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 3 files changed, 6 deletions(-) diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 1c1ebd739af62..2bfd648f90621 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -20393,8 +20393,6 @@ "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle": "Niveau de logging de l'agent", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodDescription": "Fréquence de logging des indicateurs internes d'Elastic Agent.", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodTitle": "Période de mesure de logging de l'agent", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpDescription": "Active un point de terminaison HTTP actif qui renvoie l'état d’intégrité global d'Elastic Agent. Il peut par exemple être utilisé par Kubernetes pour redémarrer le conteneur.", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpTitle": "Point de terminaison de surveillance HTTP", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutDescription": "Le délai d'expiration pour le téléchargement du binaire des agents.", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutTitle": "Délai d'expiration de téléchargement du binaire des agents", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutValidationMessage": "Doit être une chaîne avec une unité de temps, par exemple 30 s, 5 m, 2 h, 1 d", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index fbe9e93e8a768..4102f5bc6609f 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -20384,8 +20384,6 @@ "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle": "エージェントログレベル", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodDescription": "内部Elasticエージェントメトリックをログに記録する頻度。", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodTitle": "エージェントログメトリック期間", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpDescription": "Elasticエージェントの全体的な正常性を返すライブネスHTTPエンドポイントを有効化します。これは、たとえば、コンテナーを再起動するためにKubernetesによって使用されることがあります。", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpTitle": "HTTP監視エンドポイント", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutDescription": "エージェントバイナリのダウンロードに関するタイムアウト。", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutTitle": "エージェントバイナリダウンロードタイムアウト", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutValidationMessage": "30s、5m、2h、1dなどの時間単位の文字列でなければなりません", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 4d5023b6cfd61..a8f29c2650e52 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -20411,8 +20411,6 @@ "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle": "代理日志记录级别", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodDescription": "记录内部 Elastic 代理指标的频率。", "xpack.fleet.settings.agentPolicyAdvanced.agentLoggingMetricsPeriodTitle": "代理日志记录指标期间", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpDescription": "启用返回 Elastic 代理的整体运行状况的活性 HTTP 终端。例如,这可由 Kubernetes 用于重新启动容器。", - "xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpTitle": "HTTP 监测终端", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutDescription": "下载代理二进制文件时的超时值。", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutTitle": "代理二进制文件下载超时", "xpack.fleet.settings.agentPolicyAdvanced.downloadTimeoutValidationMessage": "必须为带时间单位的字符串,如 30s、5m、2h、1d", From ed3566527a763879ec084adbdf00d4db85aa8100 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:58:54 +0000 Subject: [PATCH 13/20] [CI] Auto-commit changed files from 'node scripts/check_mappings_update --fix' --- .../current_fields.json | 3 +++ .../current_mappings.json | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/kbn-check-mappings-update-cli/current_fields.json b/packages/kbn-check-mappings-update-cli/current_fields.json index ec14f4519d344..87bf8c7104871 100644 --- a/packages/kbn-check-mappings-update-cli/current_fields.json +++ b/packages/kbn-check-mappings-update-cli/current_fields.json @@ -605,8 +605,11 @@ "is_preconfigured", "is_protected", "keep_monitoring_alive", + "monitoring_diagnostics", "monitoring_enabled", + "monitoring_http", "monitoring_output_id", + "monitoring_pprof_enabled", "name", "namespace", "overrides", diff --git a/packages/kbn-check-mappings-update-cli/current_mappings.json b/packages/kbn-check-mappings-update-cli/current_mappings.json index 2bdf6e75ad1cb..7b315efcbcd4f 100644 --- a/packages/kbn-check-mappings-update-cli/current_mappings.json +++ b/packages/kbn-check-mappings-update-cli/current_mappings.json @@ -1996,13 +1996,25 @@ "keep_monitoring_alive": { "type": "boolean" }, + "monitoring_diagnostics": { + "index": false, + "type": "flattened" + }, "monitoring_enabled": { "index": false, "type": "keyword" }, + "monitoring_http": { + "index": false, + "type": "flattened" + }, "monitoring_output_id": { "type": "keyword" }, + "monitoring_pprof_enabled": { + "index": false, + "type": "boolean" + }, "name": { "type": "keyword" }, From 018f9dffae52282ac4c6323610944fad1827e7c7 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 18 Sep 2024 15:31:05 -0700 Subject: [PATCH 14/20] Remove unnecessary test for old `agent_monitoring_http` field --- .../components/form_settings/index.test.tsx | 64 ------------------- 1 file changed, 64 deletions(-) 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 fa03e9a0fd6fe..8bafc124ec36b 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,70 +102,6 @@ describe('ConfiguredSettings', () => { expect(mockUpdateAdvancedSettingsHasErrors).toHaveBeenCalledWith(true); }); - it('should render field group', () => { - const result = render([ - { - name: 'agent.monitoring.http', - api_field: { - name: 'agent_monitoring_http', - }, - title: 'Agent HTTP monitoring', - description: 'Agent HTTP monitoring settings', - learnMoreLink: - 'https://www.elastic.co/guide/en/fleet/current/enable-custom-policy-settings.html#override-default-monitoring-port', - schema: z - .object({ - enabled: z.boolean().describe('Enabled').default(false), - host: z.string().describe('Host').default('localhost'), - port: z.number().describe('Port').min(0).max(65353).default(6791), - 'buffer.enabled': z.boolean().describe('Buffer Enabled').default(false), - }) - .default({}), - }, - ]); - - expect(result.getByText('Agent HTTP monitoring')).not.toBeNull(); - expect(result.getByText('Buffer Enabled')).not.toBeNull(); - const switches = result.getAllByRole('switch'); - expect(switches).toHaveLength(2); - expect(switches[0]).not.toBeChecked(); - expect(switches[1]).not.toBeChecked(); - const port = result.getByTestId('configuredSetting-agent.monitoring.http-port'); - expect(port).toHaveValue(6791); - const host = result.getByTestId('configuredSetting-agent.monitoring.http-host'); - expect(host).toHaveValue('localhost'); - - act(() => { - fireEvent.click(switches[0]); - }); - - expect(mockUpdateAgentPolicy).toHaveBeenCalledWith( - expect.objectContaining({ - advanced_settings: expect.objectContaining({ agent_monitoring_http: { enabled: true } }), - }) - ); - - act(() => { - fireEvent.change(port, { target: { value: '6792' } }); - }); - - expect(mockUpdateAgentPolicy).toHaveBeenCalledWith( - expect.objectContaining({ - advanced_settings: expect.objectContaining({ agent_monitoring_http: { port: 6792 } }), - }) - ); - - act(() => { - fireEvent.change(host, { target: { value: '1.2.3.4' } }); - }); - - expect(mockUpdateAgentPolicy).toHaveBeenCalledWith( - expect.objectContaining({ - advanced_settings: expect.objectContaining({ agent_monitoring_http: { host: '1.2.3.4' } }), - }) - ); - }); - it('should not render field if hidden', () => { const result = render([ { From 3dc3a349ec7246d4c2b57de8c0eed90f69b355dd Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:34:07 +0000 Subject: [PATCH 15/20] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index 170cfa5958782..7f69925edf4c0 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -120,7 +120,7 @@ describe('checking migration metadata changes on all registered SO types', () => "infra-custom-dashboards": "1a5994f2e05bb8a1609825ddbf5012f77c5c67f3", "infrastructure-monitoring-log-view": "5f86709d3c27aed7a8379153b08ee5d3d90d77f5", "infrastructure-ui-source": "113182d6895764378dfe7fa9fa027244f3a457c4", - "ingest-agent-policies": "90625b4a5ded9d4867358fcccc14a57c0454fcee", + "ingest-agent-policies": "5e95e539826a40ad08fd0c1d161da0a4d86ffc6d", "ingest-download-sources": "279a68147e62e4d8858c09ad1cf03bd5551ce58d", "ingest-outputs": "daafff49255ab700e07491376fe89f04fc998b91", "ingest-package-policies": "53a94064674835fdb35e5186233bcd7052eabd22", From 1fee78bb638d76be98955b667a35976e191900fd Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 18 Sep 2024 15:52:59 -0700 Subject: [PATCH 16/20] Add API integration tests --- .../apis/agent_policy/agent_policy.ts | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts index 2bc3f68867002..14bf5550111f8 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts @@ -532,6 +532,95 @@ export default function (providerContext: FtrProviderContext) { }); } }); + + it('should create policy with advanced monitoring options', async () => { + const { + body: { item: createdPolicy }, + } = await supertest + .post(`/api/fleet/agent_policies?sys_monitoring=true`) + .set('kbn-xsrf', 'xxxx') + .send({ + name: 'advanced monitoring test', + namespace: 'default', + monitoring_pprof_enabled: true, + monitoring_http: { + host: 'localhost', + port: 6791, + enabled: true, + buffer: { + enabled: true, + }, + }, + monitoring_diagnostics: { + limit: { + interval: '1m', + burst: 1, + }, + uploader: { + max_retries: 10, + init_dur: '1s', + max_dur: '10m', + }, + }, + }) + .expect(200); + + const policyResponse = await supertest + .get(`/api/fleet/agent_policies/${createdPolicy.id}`) + .expect(200); + expect(policyResponse.body.item.monitoring_pprof_enabled).to.eql(true); + expect(policyResponse.body.item.monitoring_http).to.eql({ + host: 'localhost', + port: 6791, + enabled: true, + buffer: { + enabled: true, + }, + }); + expect(policyResponse.body.item.monitoring_diagnostics).to.eql({ + limit: { + interval: '1m', + burst: 1, + }, + uploader: { + max_retries: 10, + init_dur: '1s', + max_dur: '10m', + }, + }); + + const fullPolicyResponse = await supertest + .get(`/api/fleet/agent_policies/${createdPolicy.id}/full`) + .expect(200); + expect(fullPolicyResponse.body.item.agent.monitoring).to.eql({ + enabled: true, + logs: false, + metrics: false, + traces: false, + pprof: { + enabled: true, + }, + http: { + enabled: true, + host: 'localhost', + port: 6791, + buffer: { + enabled: true, + }, + }, + diagnostics: { + limit: { + interval: '1m', + burst: 1, + }, + uploader: { + max_retries: 10, + init_dur: '1s', + max_dur: '10m', + }, + }, + }); + }); }); describe('POST /api/fleet/agent_policies/{agentPolicyId}/copy', () => { @@ -978,6 +1067,71 @@ export default function (providerContext: FtrProviderContext) { expect(newPolicy.global_data_tags).to.eql([{ name: 'testName', value: 'testValue' }]); }); + + it('should copy advanced monitoring options', async () => { + const { + body: { item: policyWithAdvancedMonitoring }, + } = await supertest + .post(`/api/fleet/agent_policies`) + .set('kbn-xsrf', 'xxxx') + .send({ + name: 'advanced monitoring test', + namespace: 'default', + monitoring_pprof_enabled: true, + monitoring_http: { + host: 'localhost', + port: 6791, + enabled: true, + buffer: { + enabled: true, + }, + }, + monitoring_diagnostics: { + limit: { + interval: '1m', + burst: 1, + }, + uploader: { + max_retries: 10, + init_dur: '1s', + max_dur: '10m', + }, + }, + }) + .expect(200); + + const { + body: { item: newPolicy }, + } = await supertest + .post(`/api/fleet/agent_policies/${policyWithAdvancedMonitoring.id}/copy`) + .set('kbn-xsrf', 'xxxx') + .send({ + name: 'advanced monitoring test copy', + description: 'Test', + }) + .expect(200); + + expect(newPolicy.monitoring_pprof_enabled).to.eql(true); + expect(newPolicy.monitoring_http).to.eql({ + host: 'localhost', + port: 6791, + enabled: true, + buffer: { + enabled: true, + }, + }); + expect(newPolicy.monitoring_diagnostics).to.eql({ + limit: { + interval: '1m', + burst: 1, + }, + uploader: { + max_retries: 10, + init_dur: '1s', + max_dur: '10m', + }, + }); + }); }); describe('PUT /api/fleet/agent_policies/{agentPolicyId}', () => { From 57f58902ed219720a2f10fb098e09641ddc62921 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Thu, 19 Sep 2024 13:04:11 -0700 Subject: [PATCH 17/20] Fix selector in cypress test --- x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts | 2 +- .../sections/agent_policy/components/agent_policy_form.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts b/x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts index a6ec3b26c9232..d9edc61f7c0bf 100644 --- a/x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts +++ b/x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts @@ -118,7 +118,7 @@ describe('Home page', () => { 'be.visible' ); cy.getBySel(AGENT_POLICY_CREATE_AGENT_POLICY_NAME_FIELD).type('testName'); - cy.get('.ingest-active-button').click(); + cy.getBySel(AGENT_POLICIES_CREATE_AGENT_POLICY_FLYOUT.ADVANCED_OPTIONS_TOGGLE).click(); cy.getBySel(AGENT_POLICIES_FLYOUT_ADVANCED_DEFAULT_NAMESPACE_HEADER, { timeout: 15000, }).should('be.visible'); 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 66b3f41408c8f..878089bbde8e2 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 @@ -129,6 +129,7 @@ export const AgentPolicyForm: React.FunctionComponent = ({ Date: Thu, 19 Sep 2024 15:14:17 -0700 Subject: [PATCH 18/20] Remove references to `http.buffer.enabled` --- .../plugins/fleet/common/openapi/bundled.json | 34 +++------------ .../plugins/fleet/common/openapi/bundled.yaml | 17 -------- .../components/schemas/agent_policy.yaml | 7 ---- .../components/schemas/full_agent_policy.yaml | 5 --- .../fleet/common/types/models/agent_policy.ts | 2 - .../advanced_monitoring.tsx | 42 ------------------- .../model_versions/agent_policy_v4.test.ts | 6 --- .../model_versions/agent_policy_v4.ts | 6 --- .../agent_policies/full_agent_policy.test.ts | 4 -- .../agent_policies/full_agent_policy.ts | 3 -- .../apis/agent_policy/agent_policy.ts | 15 ------- 11 files changed, 5 insertions(+), 136 deletions(-) diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index 192111bd578d2..e8ee2788c7632 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -7607,17 +7607,6 @@ }, "port": { "type": "number" - }, - "buffer": { - "type": "object", - "properties": { - "enabled": { - "type": "boolean" - } - }, - "required": [ - "enabled" - ] } }, "required": [ @@ -7631,12 +7620,10 @@ "type": "object", "properties": { "interval": { - "type": "string", - "nullable": true + "type": "string" }, "burst": { - "type": "number", - "nullable": true + "type": "number" } } }, @@ -7644,16 +7631,13 @@ "type": "object", "properties": { "max_retries": { - "type": "number", - "nullable": true + "type": "number" }, "init_dur": { - "type": "string", - "nullable": true + "type": "string" }, "max_dur": { - "type": "string", - "nullable": true + "type": "string" } } } @@ -7983,14 +7967,6 @@ }, "port": { "type": "number" - }, - "buffer": { - "type": "object", - "properties": { - "enabled": { - "type": "boolean" - } - } } }, "required": [ diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index e506b2fec0378..9e8291ee3ea1d 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -4872,13 +4872,6 @@ components: type: string port: type: number - buffer: - type: object - properties: - enabled: - type: boolean - required: - - enabled required: - enabled monitoring_diagnostics: @@ -4889,22 +4882,17 @@ components: properties: interval: type: string - nullable: true burst: type: number - nullable: true uploader: type: object properties: max_retries: type: number - nullable: true init_dur: type: string - nullable: true max_dur: type: string - nullable: true required: - id - status @@ -5129,11 +5117,6 @@ components: type: string port: type: number - buffer: - type: object - properties: - enabled: - type: boolean required: - enabled diagnostics: diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml index 72b9f0fd39c8d..59f30f863c243 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml @@ -98,13 +98,6 @@ properties: type: string port: type: number - buffer: - type: object - properties: - enabled: - type: boolean - required: - - enabled required: - enabled monitoring_diagnostics: diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml index 468cf4f43359e..c901a60f59e43 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/full_agent_policy.yaml @@ -47,11 +47,6 @@ properties: type: string port: type: number - buffer: - type: object - properties: - enabled: - type: boolean required: - enabled diagnostics: 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 77fc49362ef5f..e10703f6fa0c5 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -49,7 +49,6 @@ export interface NewAgentPolicy { enabled: boolean; host?: string; port?: number; - buffer?: { enabled: boolean }; }; monitoring_diagnostics?: { limit?: { @@ -144,7 +143,6 @@ export interface FullAgentPolicyMonitoring { enabled: boolean; host?: string; port?: number; - buffer?: { enabled: boolean }; }; diagnostics?: { limit?: { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx index 1772323d51760..de765531d7c6a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/advanced_monitoring.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { EuiDescribedFormGroup, EuiSpacer, - EuiIconTip, EuiCheckbox, EuiLink, EuiAccordion, @@ -219,47 +218,6 @@ export const AgentPolicyAdvancedMonitoringOptions: React.FunctionComponent<{ - {/* Metrics buffer endpoint */} - - /buffer, - }} - />{' '} - - } - /> - - } - disabled={disabled || !agentPolicy.monitoring_http?.enabled} - checked={agentPolicy.monitoring_http?.buffer?.enabled} - onChange={(e) => { - updateTouchedFields({ 'monitoring_http.buffer.enabled': true }); - updateAgentPolicy({ - monitoring_http: { - ...agentPolicy.monitoring_http!, - buffer: { - enabled: e.target.checked, - }, - }, - }); - }} - /> - - - {/* Profiling endpoint */} { enabled: true, host: 'localhost', port: 1111, - buffer: { - enabled: true, - }, }); expect( migratedAgentPolicyDoc.attributes.advanced_settings?.agent_monitoring_http @@ -126,9 +123,6 @@ describe('migrateAgentPolicyToV8160', () => { expect(migratedAgentPolicyDoc.attributes.monitoring_http).toEqual({ enabled: true, - buffer: { - enabled: true, - }, }); expect( migratedAgentPolicyDoc.attributes.advanced_settings?.agent_monitoring_http diff --git a/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts index fbdaba60061b1..aa1b6624ab719 100644 --- a/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts +++ b/x-pack/plugins/fleet/server/saved_objects/model_versions/agent_policy_v4.ts @@ -18,12 +18,6 @@ export const backfillAgentPolicyToV4: SavedObjectModelDataBackfillFn { enabled: true, host: 'localhost', port: 1111, - buffer: { enabled: true }, }, monitoring_diagnostics: { limit: { @@ -946,7 +945,6 @@ describe('getFullMonitoringSettings', () => { enabled: true, host: 'localhost', port: 1111, - buffer: { enabled: true }, }, diagnostics: { limit: { @@ -971,7 +969,6 @@ describe('getFullMonitoringSettings', () => { monitoring_http: { enabled: true, host: 'localhost', - buffer: { enabled: false }, }, monitoring_diagnostics: { limit: { @@ -1000,7 +997,6 @@ describe('getFullMonitoringSettings', () => { http: { enabled: true, host: 'localhost', - buffer: { enabled: false }, }, diagnostics: { limit: { 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 9b76d0aa130f6..6a586364f31d5 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 @@ -566,9 +566,6 @@ export function getFullMonitoringSettings( enabled: agentPolicy.monitoring_http.enabled, ...(agentPolicy.monitoring_http.host && { host: agentPolicy.monitoring_http.host }), ...(agentPolicy.monitoring_http.port && { port: agentPolicy.monitoring_http.port }), - ...(agentPolicy.monitoring_http.buffer && { - buffer: { enabled: agentPolicy.monitoring_http.buffer.enabled }, - }), }; } diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts index 14bf5550111f8..f601743e394ec 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts @@ -547,9 +547,6 @@ export default function (providerContext: FtrProviderContext) { host: 'localhost', port: 6791, enabled: true, - buffer: { - enabled: true, - }, }, monitoring_diagnostics: { limit: { @@ -573,9 +570,6 @@ export default function (providerContext: FtrProviderContext) { host: 'localhost', port: 6791, enabled: true, - buffer: { - enabled: true, - }, }); expect(policyResponse.body.item.monitoring_diagnostics).to.eql({ limit: { @@ -604,9 +598,6 @@ export default function (providerContext: FtrProviderContext) { enabled: true, host: 'localhost', port: 6791, - buffer: { - enabled: true, - }, }, diagnostics: { limit: { @@ -1082,9 +1073,6 @@ export default function (providerContext: FtrProviderContext) { host: 'localhost', port: 6791, enabled: true, - buffer: { - enabled: true, - }, }, monitoring_diagnostics: { limit: { @@ -1116,9 +1104,6 @@ export default function (providerContext: FtrProviderContext) { host: 'localhost', port: 6791, enabled: true, - buffer: { - enabled: true, - }, }); expect(newPolicy.monitoring_diagnostics).to.eql({ limit: { From c706f3c78c09cd5e8eb3ab8327ee3fd0628edf0c Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Thu, 19 Sep 2024 15:16:35 -0700 Subject: [PATCH 19/20] Commit missed selector (???) --- x-pack/plugins/fleet/cypress/screens/fleet.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/fleet/cypress/screens/fleet.ts b/x-pack/plugins/fleet/cypress/screens/fleet.ts index 4beadbd6a8fb0..4e1a0ac0f7e19 100644 --- a/x-pack/plugins/fleet/cypress/screens/fleet.ts +++ b/x-pack/plugins/fleet/cypress/screens/fleet.ts @@ -95,6 +95,7 @@ export const AGENT_FLYOUT = { export const AGENT_POLICIES_CREATE_AGENT_POLICY_FLYOUT = { TITLE: 'createAgentPolicyFlyoutTitle', CREATE_BUTTON: 'createAgentPolicyButton', + ADVANCED_OPTIONS_TOGGLE: 'advancedOptionsButton', COLLECT_LOGS_CHECKBOX: 'collectLogsCheckbox', COLLECT_METRICS_CHECKBOX: 'collectMetricsCheckbox', }; From 3ef9b143ce386d7bedf9a6d3c54749ed53bd3d29 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 20 Sep 2024 11:47:04 -0700 Subject: [PATCH 20/20] Update doc links --- packages/kbn-doc-links/src/get_doc_links.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index 4ec364770e65c..0d7760003be6a 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -879,7 +879,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D roleAndPrivileges: `${FLEET_DOCS}fleet-roles-and-privileges.html`, proxiesSettings: `${FLEET_DOCS}fleet-agent-proxy-support.html`, unprivilegedMode: `${FLEET_DOCS}elastic-agent-unprivileged.html#unprivileged-change-mode`, - httpMonitoring: `${FLEET_DOCS}elastic-agent-monitoring-configuration.html`, + httpMonitoring: `${FLEET_DOCS}agent-policy.html#change-policy-enable-agent-monitoring`, }, integrationDeveloper: { upload: `${INTEGRATIONS_DEV_DOCS}upload-a-new-integration.html`,