From a0b08dae24a2726f0de6c0802e398b08e28ce808 Mon Sep 17 00:00:00 2001 From: Kevin Delemme Date: Wed, 7 Dec 2022 12:39:59 -0500 Subject: [PATCH 1/5] feat(slo): scaffold slo details page (#146919) --- .../slo_details/components/page_title.tsx | 24 +++++ .../components/slo_details.stories.tsx | 27 ++++++ .../slo_details/components/slo_details.tsx | 18 ++++ .../hooks/use_fetch_slo_details.ts | 73 +++++++++++++++ .../public/pages/slo_details/index.test.tsx | 92 +++++++++++++++++++ .../public/pages/slo_details/index.tsx | 67 ++++++++++++++ .../public/pages/slo_details/mocks/slo.ts | 22 +++++ .../public/pages/slo_details/translations.ts | 19 ++++ .../public/pages/slo_details/types.ts | 10 ++ .../slos/components/slo_list.stories.tsx | 2 +- .../observability/public/routes/index.tsx | 8 ++ 11 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/observability/public/pages/slo_details/components/page_title.tsx create mode 100644 x-pack/plugins/observability/public/pages/slo_details/components/slo_details.stories.tsx create mode 100644 x-pack/plugins/observability/public/pages/slo_details/components/slo_details.tsx create mode 100644 x-pack/plugins/observability/public/pages/slo_details/hooks/use_fetch_slo_details.ts create mode 100644 x-pack/plugins/observability/public/pages/slo_details/index.test.tsx create mode 100644 x-pack/plugins/observability/public/pages/slo_details/index.tsx create mode 100644 x-pack/plugins/observability/public/pages/slo_details/mocks/slo.ts create mode 100644 x-pack/plugins/observability/public/pages/slo_details/translations.ts create mode 100644 x-pack/plugins/observability/public/pages/slo_details/types.ts diff --git a/x-pack/plugins/observability/public/pages/slo_details/components/page_title.tsx b/x-pack/plugins/observability/public/pages/slo_details/components/page_title.tsx new file mode 100644 index 0000000000000..2f60ca216650d --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/components/page_title.tsx @@ -0,0 +1,24 @@ +/* + * 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 { EuiLoadingSpinner } from '@elastic/eui'; +import React from 'react'; +import { SLO } from '../../../typings'; + +export interface Props { + slo: SLO | undefined; + isLoading: boolean; +} + +export function PageTitle(props: Props) { + const { isLoading, slo } = props; + if (isLoading) { + return ; + } + + return <>{slo && slo.name}; +} diff --git a/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.stories.tsx b/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.stories.tsx new file mode 100644 index 0000000000000..11d05c95f7512 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.stories.tsx @@ -0,0 +1,27 @@ +/* + * 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 { ComponentStory } from '@storybook/react'; + +import { SloDetails as Component, Props } from './slo_details'; +import { anSLO } from '../mocks/slo'; + +export default { + component: Component, + title: 'app/SLO/DetailsPage/SloDetails', + argTypes: {}, +}; + +const Template: ComponentStory = (props: Props) => ; + +const defaultProps: Props = { + slo: anSLO, +}; + +export const SloDetails = Template.bind({}); +SloDetails.args = defaultProps; diff --git a/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.tsx b/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.tsx new file mode 100644 index 0000000000000..62e2d1d1be0d0 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/components/slo_details.tsx @@ -0,0 +1,18 @@ +/* + * 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 { SLO } from '../../../typings'; + +export interface Props { + slo: SLO; +} + +export function SloDetails(props: Props) { + const { slo } = props; + return
{JSON.stringify(slo, null, 2)}
; +} diff --git a/x-pack/plugins/observability/public/pages/slo_details/hooks/use_fetch_slo_details.ts b/x-pack/plugins/observability/public/pages/slo_details/hooks/use_fetch_slo_details.ts new file mode 100644 index 0000000000000..6044f8a9ba8d4 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/hooks/use_fetch_slo_details.ts @@ -0,0 +1,73 @@ +/* + * 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 { HttpSetup } from '@kbn/core-http-browser'; +import { useCallback, useMemo } from 'react'; +import { useDataFetcher } from '../../../hooks/use_data_fetcher'; +import { SLO } from '../../../typings'; + +interface UseFetchSloDetailsResponse { + loading: boolean; + slo: SLO | undefined; +} + +function useFetchSloDetails(sloId: string): UseFetchSloDetailsResponse { + const params = useMemo(() => ({ sloId }), [sloId]); + const shouldExecuteApiCall = useCallback( + (apiCallParams: { sloId: string }) => params.sloId === apiCallParams.sloId, + [params] + ); + + const { loading, data: slo } = useDataFetcher<{ sloId: string }, SLO | undefined>({ + paramsForApiCall: params, + initialDataState: undefined, + executeApiCall: fetchSlo, + shouldExecuteApiCall, + }); + + return { loading, slo }; +} + +const fetchSlo = async ( + params: { sloId: string }, + abortController: AbortController, + http: HttpSetup +): Promise => { + try { + const response = await http.get>( + `/api/observability/slos/${params.sloId}`, + { + query: {}, + signal: abortController.signal, + } + ); + if (response !== undefined) { + return toSLO(response); + } + } catch (error) { + // ignore error for retrieving slos + } + + return undefined; +}; + +function toSLO(result: any): SLO { + return { + id: String(result.id), + name: String(result.name), + objective: { target: Number(result.objective.target) }, + summary: { + sliValue: Number(result.summary.sli_value), + errorBudget: { + remaining: Number(result.summary.error_budget.remaining), + }, + }, + }; +} + +export type { UseFetchSloDetailsResponse }; +export { useFetchSloDetails }; diff --git a/x-pack/plugins/observability/public/pages/slo_details/index.test.tsx b/x-pack/plugins/observability/public/pages/slo_details/index.test.tsx new file mode 100644 index 0000000000000..fa40471708eec --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/index.test.tsx @@ -0,0 +1,92 @@ +/* + * 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 { screen } from '@testing-library/react'; + +import { ConfigSchema } from '../../plugin'; +import { Subset } from '../../typings'; +import { useKibana } from '../../utils/kibana_react'; +import { kibanaStartMock } from '../../utils/kibana_react.mock'; +import { render } from '../../utils/test_helper'; +import { SloDetailsPage } from '.'; +import { useFetchSloDetails } from './hooks/use_fetch_slo_details'; +import { anSLO } from './mocks/slo'; +import { useParams } from 'react-router-dom'; + +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useParams: jest.fn(), +})); + +jest.mock('./hooks/use_fetch_slo_details'); +jest.mock('../../utils/kibana_react'); +jest.mock('../../hooks/use_breadcrumbs'); + +const useFetchSloDetailsMock = useFetchSloDetails as jest.Mock; +const useParamsMock = useParams as jest.Mock; +const useKibanaMock = useKibana as jest.Mock; +const mockKibana = () => { + useKibanaMock.mockReturnValue({ + services: { + ...kibanaStartMock.startContract(), + http: { + basePath: { + prepend: jest.fn(), + }, + }, + }, + }); +}; + +const config: Subset = { + unsafe: { + slo: { enabled: true }, + }, +}; + +describe('SLO Details Page', () => { + beforeEach(() => { + jest.clearAllMocks(); + mockKibana(); + }); + + it('renders the not found page when the feature flag is not enabled', async () => { + useParamsMock.mockReturnValue(anSLO.id); + useFetchSloDetailsMock.mockReturnValue({ loading: false, slo: anSLO }); + render(, { unsafe: { slo: { enabled: false } } }); + + expect(screen.queryByTestId('pageNotFound')).toBeTruthy(); + }); + + it('renders the not found page when the SLO cannot be found', async () => { + useParamsMock.mockReturnValue('inexistant'); + useFetchSloDetailsMock.mockReturnValue({ loading: false, slo: undefined }); + render(, config); + + expect(screen.queryByTestId('pageNotFound')).toBeTruthy(); + }); + + it('renders the loading spiner when fetching the SLO', async () => { + useParamsMock.mockReturnValue(anSLO.id); + useFetchSloDetailsMock.mockReturnValue({ loading: true, slo: undefined }); + render(, config); + + expect(screen.queryByTestId('pageNotFound')).toBeFalsy(); + expect(screen.queryByTestId('loadingTitle')).toBeTruthy(); + expect(screen.queryByTestId('loadingDetails')).toBeTruthy(); + }); + + it('renders the SLO details page when the feature flag is enabled', async () => { + useParamsMock.mockReturnValue(anSLO.id); + useFetchSloDetailsMock.mockReturnValue({ loading: false, slo: anSLO }); + render(, config); + + expect(screen.queryByTestId('sloDetailsPage')).toBeTruthy(); + expect(screen.queryByTestId('sloDetails')).toBeTruthy(); + }); +}); diff --git a/x-pack/plugins/observability/public/pages/slo_details/index.tsx b/x-pack/plugins/observability/public/pages/slo_details/index.tsx new file mode 100644 index 0000000000000..45a46e4d89490 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/index.tsx @@ -0,0 +1,67 @@ +/* + * 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 { useParams } from 'react-router-dom'; +import { IBasePath } from '@kbn/core-http-browser'; +import { EuiBreadcrumbProps } from '@elastic/eui/src/components/breadcrumbs/breadcrumb'; +import { EuiLoadingSpinner } from '@elastic/eui'; +import { ObservabilityAppServices } from '../../application/types'; +import { paths } from '../../config'; +import { usePluginContext } from '../../hooks/use_plugin_context'; +import { useBreadcrumbs } from '../../hooks/use_breadcrumbs'; +import { useKibana } from '../../utils/kibana_react'; +import PageNotFound from '../404'; +import { isSloFeatureEnabled } from '../slos/helpers'; +import { SLOS_BREADCRUMB_TEXT } from '../slos/translations'; +import { SloDetailsPathParams } from './types'; +import { useFetchSloDetails } from './hooks/use_fetch_slo_details'; +import { SLO } from '../../typings'; +import { SloDetails } from './components/slo_details'; +import { SLO_DETAILS_BREADCRUMB_TEXT } from './translations'; +import { PageTitle } from './components/page_title'; + +export function SloDetailsPage() { + const { http } = useKibana().services; + const { ObservabilityPageTemplate, config } = usePluginContext(); + const { sloId } = useParams(); + + const { loading, slo } = useFetchSloDetails(sloId); + useBreadcrumbs(getBreadcrumbs(http.basePath, slo)); + + const isSloNotFound = !loading && slo === undefined; + if (!isSloFeatureEnabled(config) || isSloNotFound) { + return ; + } + + return ( + , + rightSideItems: [], + bottomBorder: true, + }} + data-test-subj="sloDetailsPage" + > + {loading && } + {!loading && } + + ); +} + +function getBreadcrumbs(basePath: IBasePath, slo: SLO | undefined): EuiBreadcrumbProps[] { + return [ + { + href: basePath.prepend(paths.observability.slos), + text: SLOS_BREADCRUMB_TEXT, + }, + { + text: slo?.name ?? SLO_DETAILS_BREADCRUMB_TEXT, + }, + ]; +} diff --git a/x-pack/plugins/observability/public/pages/slo_details/mocks/slo.ts b/x-pack/plugins/observability/public/pages/slo_details/mocks/slo.ts new file mode 100644 index 0000000000000..a657629bd5ecb --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/mocks/slo.ts @@ -0,0 +1,22 @@ +/* + * 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 { SLO } from '../../../typings'; + +export const anSLO: SLO = { + id: '2f17deb0-725a-11ed-ab7c-4bb641cfc57e', + name: 'SLO latency service log', + objective: { + target: 0.98, + }, + summary: { + sliValue: 0.990097, + errorBudget: { + remaining: 0.504831, + }, + }, +}; diff --git a/x-pack/plugins/observability/public/pages/slo_details/translations.ts b/x-pack/plugins/observability/public/pages/slo_details/translations.ts new file mode 100644 index 0000000000000..d35784350834a --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/translations.ts @@ -0,0 +1,19 @@ +/* + * 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 { i18n } from '@kbn/i18n'; + +export const SLO_DETAILS_PAGE_TITLE = i18n.translate('xpack.observability.sloDetailsPageTitle', { + defaultMessage: 'SLO Details', +}); + +export const SLO_DETAILS_BREADCRUMB_TEXT = i18n.translate( + 'xpack.observability.breadcrumbs.sloDetailsLinkText', + { + defaultMessage: 'Details', + } +); diff --git a/x-pack/plugins/observability/public/pages/slo_details/types.ts b/x-pack/plugins/observability/public/pages/slo_details/types.ts new file mode 100644 index 0000000000000..46aaa1b02f38b --- /dev/null +++ b/x-pack/plugins/observability/public/pages/slo_details/types.ts @@ -0,0 +1,10 @@ +/* + * 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. + */ + +export interface SloDetailsPathParams { + sloId: string; +} diff --git a/x-pack/plugins/observability/public/pages/slos/components/slo_list.stories.tsx b/x-pack/plugins/observability/public/pages/slos/components/slo_list.stories.tsx index 72ababa52d7da..eabf09ce9be26 100644 --- a/x-pack/plugins/observability/public/pages/slos/components/slo_list.stories.tsx +++ b/x-pack/plugins/observability/public/pages/slos/components/slo_list.stories.tsx @@ -12,7 +12,7 @@ import { SloList as Component } from './slo_list'; export default { component: Component, - title: 'app/SLOs/SloList', + title: 'app/SLO/ListPage/SloList', argTypes: {}, }; diff --git a/x-pack/plugins/observability/public/routes/index.tsx b/x-pack/plugins/observability/public/routes/index.tsx index 98dd2b6c70d7b..20cf331842a55 100644 --- a/x-pack/plugins/observability/public/routes/index.tsx +++ b/x-pack/plugins/observability/public/routes/index.tsx @@ -21,6 +21,7 @@ import { AlertingPages } from '../config'; import { AlertDetails } from '../pages/alert_details'; import { DatePickerContextProvider } from '../context/date_picker_context'; import { SlosPage } from '../pages/slos'; +import { SloDetailsPage } from '../pages/slo_details'; export type RouteParams = DecodeParams; @@ -137,4 +138,11 @@ export const routes = { params: {}, exact: true, }, + '/slos/:sloId': { + handler: () => { + return ; + }, + params: {}, + exact: true, + }, }; From 42319a79b36481c00f278898ae20d7b37bba5e27 Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Wed, 7 Dec 2022 18:43:28 +0100 Subject: [PATCH 2/5] fix cyclic imports in core packages (#147200) --- .../src/elasticsearch_client.test.ts | 8 +++++++- .../src/utils/get_index_for_type.test.ts | 12 +++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/core/metrics/core-metrics-collectors-server-internal/src/elasticsearch_client.test.ts b/packages/core/metrics/core-metrics-collectors-server-internal/src/elasticsearch_client.test.ts index 363fca6430dbe..49b5a4b71da53 100644 --- a/packages/core/metrics/core-metrics-collectors-server-internal/src/elasticsearch_client.test.ts +++ b/packages/core/metrics/core-metrics-collectors-server-internal/src/elasticsearch_client.test.ts @@ -8,7 +8,7 @@ import { Agent as HttpAgent } from 'http'; import { Agent as HttpsAgent } from 'https'; -import { sampleEsClientMetrics } from '@kbn/core-metrics-server-mocks'; +import type { ElasticsearchClientsMetrics } from '@kbn/core-metrics-server'; import { createAgentStoreMock } from '@kbn/core-elasticsearch-client-server-mocks'; import { getAgentsSocketsStatsMock } from './get_agents_sockets_stats.test.mocks'; import { ElasticsearchClientsMetricsCollector } from './elasticsearch_client'; @@ -16,6 +16,12 @@ import { getAgentsSocketsStats } from './get_agents_sockets_stats'; jest.mock('@kbn/core-elasticsearch-client-server-internal'); +export const sampleEsClientMetrics: ElasticsearchClientsMetrics = { + totalActiveSockets: 25, + totalIdleSockets: 2, + totalQueuedRequests: 0, +}; + describe('ElasticsearchClientsMetricsCollector', () => { test('#collect calls getAgentsSocketsStats with the Agents managed by the provided AgentManager', async () => { const agents = new Set([new HttpAgent(), new HttpsAgent()]); diff --git a/packages/core/saved-objects/core-saved-objects-base-server-internal/src/utils/get_index_for_type.test.ts b/packages/core/saved-objects/core-saved-objects-base-server-internal/src/utils/get_index_for_type.test.ts index 01bb3174cc56b..551c9dc1187eb 100644 --- a/packages/core/saved-objects/core-saved-objects-base-server-internal/src/utils/get_index_for_type.test.ts +++ b/packages/core/saved-objects/core-saved-objects-base-server-internal/src/utils/get_index_for_type.test.ts @@ -6,16 +6,22 @@ * Side Public License, v 1. */ -import { typeRegistryMock } from '@kbn/core-saved-objects-base-server-mocks'; +import { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server'; import { getIndexForType } from './get_index_for_type'; +const createTypeRegistry = () => { + return { + getIndex: jest.fn(), + } as unknown as jest.Mocked; +}; + describe('getIndexForType', () => { const kibanaVersion = '8.0.0'; const defaultIndex = '.kibana'; - let typeRegistry: ReturnType; + let typeRegistry: ReturnType; beforeEach(() => { - typeRegistry = typeRegistryMock.create(); + typeRegistry = createTypeRegistry(); }); it('returns the correct index for a type specifying a custom index', () => { From 29d274576bc577a9af68d3bca7d04dea4b2dd27d Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 7 Dec 2022 12:53:31 -0500 Subject: [PATCH 3/5] [Fleet] Remove preconfiguration API route (#147199) --- .../plugins/fleet/common/constants/routes.ts | 1 - .../plugins/fleet/common/openapi/bundled.json | 205 ------------------ .../plugins/fleet/common/openapi/bundled.yaml | 129 ----------- .../schemas/preconfiguration_error.yaml | 26 --- .../schemas/preconfigured_agent_policies.yaml | 84 ------- .../fleet/common/openapi/entrypoint.yaml | 2 - .../openapi/paths/setup_preconfiguration.yaml | 43 ---- .../server/routes/preconfiguration/handler.ts | 42 +--- .../server/routes/preconfiguration/index.ts | 22 +- .../test/fleet_api_integration/apis/index.js | 3 - .../apis/preconfiguration/index.js | 12 - .../apis/preconfiguration/preconfiguration.ts | 49 ----- 12 files changed, 3 insertions(+), 615 deletions(-) delete mode 100644 x-pack/plugins/fleet/common/openapi/components/schemas/preconfiguration_error.yaml delete mode 100644 x-pack/plugins/fleet/common/openapi/components/schemas/preconfigured_agent_policies.yaml delete mode 100644 x-pack/plugins/fleet/common/openapi/paths/setup_preconfiguration.yaml delete mode 100644 x-pack/test/fleet_api_integration/apis/preconfiguration/index.js delete mode 100644 x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts diff --git a/x-pack/plugins/fleet/common/constants/routes.ts b/x-pack/plugins/fleet/common/constants/routes.ts index ff30b1fcd3f59..c5bb030a7d997 100644 --- a/x-pack/plugins/fleet/common/constants/routes.ts +++ b/x-pack/plugins/fleet/common/constants/routes.ts @@ -175,7 +175,6 @@ export const INSTALL_SCRIPT_API_ROUTES = `${API_ROOT}/install/{osType}`; // Policy preconfig API routes export const PRECONFIGURATION_API_ROUTES = { - UPDATE_PATTERN: `${API_ROOT}/setup/preconfiguration`, RESET_PATTERN: `${INTERNAL_ROOT}/reset_preconfigured_agent_policies`, RESET_ONE_PATTERN: `${INTERNAL_ROOT}/reset_preconfigured_agent_policies/{agentPolicyId}`, }; diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index 37b4e4800557f..406907f9a7d4c 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -59,76 +59,6 @@ ] } }, - "/setup/preconfiguration": { - "put": { - "summary": "Preconfiguration", - "operationId": "put-preconfiguration", - "tags": [], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "agentPolicies": { - "type": "object", - "items": {} - }, - "packages": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "body": { - "type": "object", - "properties": { - "agentPolicies": { - "$ref": "#/components/schemas/preconfigured_agent_policies" - }, - "packages": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "required": [ - "name", - "version" - ] - } - } - } - } - } - } - } - } - } - }, "/settings": { "get": { "summary": "Settings", @@ -4496,141 +4426,6 @@ "nonFatalErrors" ] }, - "preconfigured_agent_policies": { - "title": "Preconfigured agent policies", - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "is_managed": { - "type": "string" - }, - "unenroll_timeout": { - "type": "number" - }, - "monitoring_enabled": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "logs", - "metrics" - ] - } - }, - "namespace": { - "type": "string" - }, - "id": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "is_default": { - "type": "boolean", - "deprecated": true - }, - "is_default_fleet_server": { - "type": "boolean", - "deprecated": true - }, - "has_fleet_server": { - "type": "boolean" - }, - "data_output_id": { - "type": "string" - }, - "monitoring_output_id": { - "type": "string" - }, - "package_policies": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "name": { - "type": "string" - }, - "package": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - } - }, - "description": { - "type": "string" - }, - "namespace": { - "type": "string" - }, - "inputs": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "enabled": { - "type": "boolean" - }, - "keep_enabled": { - "type": "boolean" - }, - "vars": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "value": { - "type": "string" - }, - "frozen": { - "type": "boolean" - } - } - } - }, - "required": [ - "type" - ] - } - } - } - } - } - }, - "required": [ - "name", - "namespace", - "package_policies" - ] - }, "settings": { "title": "Settings", "type": "object", diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index 95fcd9513b467..cd4fdc3a45593 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -36,50 +36,6 @@ paths: operationId: setup parameters: - $ref: '#/components/parameters/kbn_xsrf' - /setup/preconfiguration: - put: - summary: Preconfiguration - operationId: put-preconfiguration - tags: [] - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - agentPolicies: - type: object - items: {} - packages: - type: object - properties: - name: - type: string - version: - type: string - requestBody: - content: - application/json: - schema: - type: object - properties: - body: - type: object - properties: - agentPolicies: - $ref: '#/components/schemas/preconfigured_agent_policies' - packages: - type: object - properties: - name: - type: string - version: - type: string - required: - - name - - version /settings: get: summary: Settings @@ -2797,91 +2753,6 @@ components: required: - isInitialized - nonFatalErrors - preconfigured_agent_policies: - title: Preconfigured agent policies - type: object - properties: - name: - type: string - description: - type: string - is_managed: - type: string - unenroll_timeout: - type: number - monitoring_enabled: - type: array - items: - type: string - enum: - - logs - - metrics - namespace: - type: string - id: - oneOf: - - type: string - - type: number - is_default: - type: boolean - deprecated: true - is_default_fleet_server: - type: boolean - deprecated: true - has_fleet_server: - type: boolean - data_output_id: - type: string - monitoring_output_id: - type: string - package_policies: - type: array - items: - type: object - properties: - id: - oneOf: - - type: string - - type: number - name: - type: string - package: - type: object - properties: - name: - type: string - description: - type: string - namespace: - type: string - inputs: - type: array - items: - type: object - properties: - type: - type: string - enabled: - type: boolean - keep_enabled: - type: boolean - vars: - type: object - properties: - name: - type: string - type: - type: string - value: - type: string - frozen: - type: boolean - required: - - type - required: - - name - - namespace - - package_policies settings: title: Settings type: object diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/preconfiguration_error.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/preconfiguration_error.yaml deleted file mode 100644 index 147488d3e78d8..0000000000000 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/preconfiguration_error.yaml +++ /dev/null @@ -1,26 +0,0 @@ -title: Preconfiguration Error -type: object -properties: - package: - type: object - properties: - name: - type: string - version: - type: string - agentPolicy: - type: object - properties: - name: - type: string - error: - type: object - properties: - name: - type: string - message: - type: string - stack: - type: string - required: - - error diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/preconfigured_agent_policies.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/preconfigured_agent_policies.yaml deleted file mode 100644 index 84feaf8fdeb91..0000000000000 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/preconfigured_agent_policies.yaml +++ /dev/null @@ -1,84 +0,0 @@ -title: Preconfigured agent policies -type: object -properties: - name: - type: string - description: - type: string - is_managed: - type: string - unenroll_timeout: - type: number - monitoring_enabled: - type: array - items: - type: string - enum: - - 'logs' - - 'metrics' - namespace: - type: string - id: - oneOf: - - type: string - - type: number - is_default: - type: boolean - deprecated: true - is_default_fleet_server: - type: boolean - deprecated: true - has_fleet_server: - type: boolean - data_output_id: - type: string - monitoring_output_id: - type: string - package_policies: - type: array - items: - type: object - properties: - id: - oneOf: - - type: string - - type: number - name: - type: string - package: - type: object - properties: - name: - type: string - description: - type: string - namespace: - type: string - inputs: - type: array - items: - type: object - properties: - type: - type: string - enabled: - type: boolean - keep_enabled: - type: boolean - vars: - type: object - properties: - name: - type: string - type: - type: string - value: - type: string - frozen: - type: boolean - required: - - type -required: - - name - - namespace - - package_policies diff --git a/x-pack/plugins/fleet/common/openapi/entrypoint.yaml b/x-pack/plugins/fleet/common/openapi/entrypoint.yaml index db0a25a8e55b3..648f11b5ad706 100644 --- a/x-pack/plugins/fleet/common/openapi/entrypoint.yaml +++ b/x-pack/plugins/fleet/common/openapi/entrypoint.yaml @@ -16,8 +16,6 @@ paths: # plugin-wide endpoint(s) /setup: $ref: paths/setup.yaml - /setup/preconfiguration: - $ref: paths/setup_preconfiguration.yaml /settings: $ref: paths/settings.yaml # App endpoints diff --git a/x-pack/plugins/fleet/common/openapi/paths/setup_preconfiguration.yaml b/x-pack/plugins/fleet/common/openapi/paths/setup_preconfiguration.yaml deleted file mode 100644 index a01536b5634f6..0000000000000 --- a/x-pack/plugins/fleet/common/openapi/paths/setup_preconfiguration.yaml +++ /dev/null @@ -1,43 +0,0 @@ -put: - summary: Preconfiguration - operationId: put-preconfiguration - tags: [] - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - agentPolicies: - type: object - items: {} - packages: - type: object - properties: - name: - type: string - version: - type: string - requestBody: - content: - application/json: - schema: - type: object - properties: - body: - type: object - properties: - agentPolicies: - $ref: ../components/schemas/preconfigured_agent_policies.yaml - packages: - type: object - properties: - name: - type: string - version: - type: string - required: - - name - - version diff --git a/x-pack/plugins/fleet/server/routes/preconfiguration/handler.ts b/x-pack/plugins/fleet/server/routes/preconfiguration/handler.ts index 64f98746a19f9..7b2956b7ec460 100644 --- a/x-pack/plugins/fleet/server/routes/preconfiguration/handler.ts +++ b/x-pack/plugins/fleet/server/routes/preconfiguration/handler.ts @@ -7,51 +7,11 @@ import type { TypeOf } from '@kbn/config-schema'; -import type { PreconfiguredAgentPolicy } from '../../../common/types'; - import type { FleetRequestHandler } from '../../types'; -import type { - PutPreconfigurationSchema, - PostResetOnePreconfiguredAgentPoliciesSchema, -} from '../../types'; +import type { PostResetOnePreconfiguredAgentPoliciesSchema } from '../../types'; import { defaultFleetErrorHandler } from '../../errors'; -import { - ensurePreconfiguredPackagesAndPolicies, - outputService, - downloadSourceService, -} from '../../services'; import { resetPreconfiguredAgentPolicies } from '../../services/preconfiguration/reset_agent_policies'; -export const updatePreconfigurationHandler: FleetRequestHandler< - undefined, - undefined, - TypeOf -> = async (context, request, response) => { - const coreContext = await context.core; - const fleetContext = await context.fleet; - const soClient = coreContext.savedObjects.client; - const esClient = coreContext.elasticsearch.client.asInternalUser; - const defaultOutput = await outputService.ensureDefaultOutput(soClient); - const defaultDownloadSource = await downloadSourceService.ensureDefault(soClient); - const spaceId = fleetContext.spaceId; - const { agentPolicies, packages } = request.body; - - try { - const body = await ensurePreconfiguredPackagesAndPolicies( - soClient, - esClient, - (agentPolicies as PreconfiguredAgentPolicy[]) ?? [], - packages ?? [], - defaultOutput, - defaultDownloadSource, - spaceId - ); - return response.ok({ body }); - } catch (error) { - return defaultFleetErrorHandler({ error, response }); - } -}; - export const resetOnePreconfigurationHandler: FleetRequestHandler< TypeOf, undefined, diff --git a/x-pack/plugins/fleet/server/routes/preconfiguration/index.ts b/x-pack/plugins/fleet/server/routes/preconfiguration/index.ts index 38651b15f939d..9f5f372298530 100644 --- a/x-pack/plugins/fleet/server/routes/preconfiguration/index.ts +++ b/x-pack/plugins/fleet/server/routes/preconfiguration/index.ts @@ -6,17 +6,10 @@ */ import { PRECONFIGURATION_API_ROUTES } from '../../constants'; -import { - PutPreconfigurationSchema, - PostResetOnePreconfiguredAgentPoliciesSchema, -} from '../../types'; +import { PostResetOnePreconfiguredAgentPoliciesSchema } from '../../types'; import type { FleetAuthzRouter } from '../security'; -import { - updatePreconfigurationHandler, - resetPreconfigurationHandler, - resetOnePreconfigurationHandler, -} from './handler'; +import { resetPreconfigurationHandler, resetOnePreconfigurationHandler } from './handler'; export const registerRoutes = (router: FleetAuthzRouter) => { router.post( @@ -39,15 +32,4 @@ export const registerRoutes = (router: FleetAuthzRouter) => { }, resetOnePreconfigurationHandler ); - - router.put( - { - path: PRECONFIGURATION_API_ROUTES.UPDATE_PATTERN, - validate: PutPreconfigurationSchema, - fleetAuthz: { - fleet: { all: true }, - }, - }, - updatePreconfigurationHandler - ); }; diff --git a/x-pack/test/fleet_api_integration/apis/index.js b/x-pack/test/fleet_api_integration/apis/index.js index f264a4fb8134a..60235bb6fc482 100644 --- a/x-pack/test/fleet_api_integration/apis/index.js +++ b/x-pack/test/fleet_api_integration/apis/index.js @@ -41,9 +41,6 @@ export default function ({ loadTestFile, getService }) { // Settings loadTestFile(require.resolve('./settings')); - // Preconfiguration - loadTestFile(require.resolve('./preconfiguration')); - // Service tokens loadTestFile(require.resolve('./service_tokens')); diff --git a/x-pack/test/fleet_api_integration/apis/preconfiguration/index.js b/x-pack/test/fleet_api_integration/apis/preconfiguration/index.js deleted file mode 100644 index 9b97cda898a0e..0000000000000 --- a/x-pack/test/fleet_api_integration/apis/preconfiguration/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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. - */ - -export default function loadTests({ loadTestFile }) { - describe('Preconfiguration Endpoints', () => { - loadTestFile(require.resolve('./preconfiguration')); - }); -} diff --git a/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts b/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts deleted file mode 100644 index 83d2913e7aa59..0000000000000 --- a/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 expect from '@kbn/expect'; -import { PRECONFIGURATION_API_ROUTES } from '@kbn/fleet-plugin/common/constants'; -import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; -import { skipIfNoDockerRegistry } from '../../helpers'; - -export default function (providerContext: FtrProviderContext) { - const { getService } = providerContext; - const supertest = getService('supertest'); - - // use function () {} and not () => {} here - // because `this` has to point to the Mocha context - // see https://mochajs.org/#arrow-functions - - describe('Preconfiguration', async () => { - skipIfNoDockerRegistry(providerContext); - before(async () => { - await getService('kibanaServer').savedObjects.cleanStandardList(); - - await getService('esArchiver').load( - 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' - ); - }); - - after(async () => { - await getService('esArchiver').unload( - 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' - ); - await getService('kibanaServer').savedObjects.cleanStandardList(); - }); - - // Basic health check for the API; functionality is covered by the unit tests - it('should succeed with an empty payload', async () => { - const { body } = await supertest - .put(PRECONFIGURATION_API_ROUTES.UPDATE_PATTERN) - .set('kbn-xsrf', 'xxxx') - .send({}) - .expect(200); - - expect(body.nonFatalErrors).to.eql([]); - }); - }); -} From 852299b535c054e8fa469d5a55a9bbc73b55d280 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 7 Dec 2022 19:02:15 +0100 Subject: [PATCH 4/5] [performance] add APM data set extraction pipeline (#147177) ## Summary Part of #140828 PR for run yml file [elastic/kibana-buildkite/pull/67](https://github.com/elastic/kibana-buildkite/pull/67) This PR moves data set extraction step in separate pipeline, still reporting KIbana scalability and ES Rally output in Kibana-related bucket. Reporting ES Rally data to required bucket will be added in the follow-up PR. --- .buildkite/pipelines/performance/daily.yml | 6 --- .../performance/data_set_extraction_daily.yml | 43 +++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .buildkite/pipelines/performance/data_set_extraction_daily.yml diff --git a/.buildkite/pipelines/performance/daily.yml b/.buildkite/pipelines/performance/daily.yml index ea7e406ba63d8..70929ddc43be6 100644 --- a/.buildkite/pipelines/performance/daily.yml +++ b/.buildkite/pipelines/performance/daily.yml @@ -27,12 +27,6 @@ steps: - exit_status: '*' limit: 1 - - label: '🚢 Performance Tests dataset extraction for scalability benchmarking' - command: .buildkite/scripts/steps/functional/scalability_dataset_extraction.sh - agents: - queue: n2-2 - depends_on: tests - - label: '📈 Report performance metrics to ci-stats' command: .buildkite/scripts/steps/functional/report_performance_metrics.sh agents: diff --git a/.buildkite/pipelines/performance/data_set_extraction_daily.yml b/.buildkite/pipelines/performance/data_set_extraction_daily.yml new file mode 100644 index 0000000000000..77d410ab29c2e --- /dev/null +++ b/.buildkite/pipelines/performance/data_set_extraction_daily.yml @@ -0,0 +1,43 @@ +steps: + - label: ':male-mechanic::skin-tone-2: Pre-Build' + command: .buildkite/scripts/lifecycle/pre_build.sh + agents: + queue: kibana-default + timeout_in_minutes: 10 + + - wait + + - label: ':building_construction: Build Kibana Distribution and Plugins' + command: .buildkite/scripts/steps/build_kibana.sh + agents: + queue: c2-16 + key: build + if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''" + + - label: ':kibana: Performance Tests with Playwright config' + command: .buildkite/scripts/steps/functional/performance_playwright.sh + agents: + queue: n2-2-spot + depends_on: build + key: tests + timeout_in_minutes: 60 + retry: + automatic: + - exit_status: '-1' + limit: 3 + - exit_status: '*' + limit: 1 + + - label: ':ship: Single user journeys dataset extraction for scalability benchmarking' + command: .buildkite/scripts/steps/functional/scalability_dataset_extraction.sh + agents: + queue: n2-2 + depends_on: tests + + - wait: ~ + continue_on_failure: true + + - label: ':male_superhero::skin-tone-2: Post-Build' + command: .buildkite/scripts/lifecycle/post_build.sh + agents: + queue: kibana-default From 8f71351a9485f4871ef033c59ec26cfb33928338 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 7 Dec 2022 14:59:28 -0500 Subject: [PATCH 5/5] [Fleet] Improve package policy open API doc (#147144) --- .../plugins/fleet/common/openapi/bundled.json | 194 +++++------------- .../plugins/fleet/common/openapi/bundled.yaml | 124 +++-------- ...olicy.yaml => package_policy_request.yaml} | 21 +- .../openapi/paths/package_policies.yaml | 15 +- .../package_policies@{package_policy_id}.yaml | 22 +- 5 files changed, 109 insertions(+), 267 deletions(-) rename x-pack/plugins/fleet/common/openapi/components/schemas/{simplified_package_policy.yaml => package_policy_request.yaml} (78%) diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index 406907f9a7d4c..db8470ed48fd5 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -2959,35 +2959,7 @@ "content": { "application/json": { "schema": { - "oneOf": [ - { - "$ref": "#/components/schemas/simplified_package_policy" - }, - { - "deprecated": true, - "allOf": [ - { - "$ref": "#/components/schemas/new_package_policy" - }, - { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - { - "type": "object", - "properties": { - "force": { - "type": "boolean" - } - } - } - ] - } - ] + "$ref": "#/components/schemas/package_policy_request" } } } @@ -3276,7 +3248,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/update_package_policy" + "$ref": "#/components/schemas/package_policy_request" } } } @@ -3287,25 +3259,18 @@ "content": { "application/json": { "schema": { - "oneOf": [ - { - "$ref": "#/components/schemas/simplified_package_policy" + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/package_policy" }, - { - "type": "object", - "properties": { - "item": { - "$ref": "#/components/schemas/package_policy" - }, - "sucess": { - "type": "boolean" - } - }, - "required": [ - "item", - "sucess" - ] + "sucess": { + "type": "boolean" } + }, + "required": [ + "item", + "sucess" ] } } @@ -5524,8 +5489,8 @@ "created_at" ] }, - "simplified_package_policy": { - "title": "Simplified Package Policy", + "package_policy_request": { + "title": "Package Policy Request", "type": "object", "properties": { "id": { @@ -5534,30 +5499,36 @@ }, "name": { "type": "string", - "description": "Package policy name (should be unique)" + "description": "Package policy name (should be unique)", + "example": "nginx-123" }, "description": { "type": "string", - "description": "Package policy description" + "description": "Package policy description", + "example": "my description" }, "namespace": { "type": "string", - "description": "namespace by default \"default\"" + "description": "namespace by default \"default\"", + "example": "default" }, "policy_id": { "type": "string", - "description": "Agent policy ID where that package policy will be added" + "description": "Agent policy ID to which the package policy will be added", + "example": "agent-policy-id" }, "package": { "type": "object", "properties": { "name": { "type": "string", - "description": "Package name" + "description": "Package name", + "example": "nginx" }, "version": { "type": "string", - "description": "Package version" + "description": "Package version", + "example": "1.6.0" } }, "required": [ @@ -5572,6 +5543,26 @@ "inputs": { "type": "object", "description": "Package policy inputs (see integration documentation to know what inputs are available)", + "example": { + "nginx-logfile": { + "enabled": true, + "streams": { + "nginx.access": { + "enabled": true, + "vars": { + "paths": [ + "/var/log/nginx/access.log*" + ], + "tags": [ + "nginx-access" + ], + "preserve_original_event": false, + "ignore_older": "72h" + } + } + } + } + }, "additionalProperties": { "type": "object", "properties": { @@ -5770,99 +5761,6 @@ } } }, - "update_package_policy": { - "title": "Update package policy", - "type": "object", - "description": "", - "properties": { - "version": { - "type": "string" - }, - "enabled": { - "type": "boolean" - }, - "package": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "title": { - "type": "string" - } - }, - "required": [ - "name", - "title", - "version" - ] - }, - "namespace": { - "type": "string" - }, - "output_id": { - "type": "string", - "description": "Not supported output can be set at the agent policy level only", - "deprecated": true - }, - "inputs": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "enabled": { - "type": "boolean" - }, - "processors": { - "type": "array", - "items": { - "type": "string" - } - }, - "streams": { - "type": "array", - "items": {} - }, - "config": { - "type": "object" - }, - "vars": { - "type": "object" - } - }, - "required": [ - "type", - "enabled", - "streams" - ] - } - }, - "policy_id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "force": { - "type": "boolean" - } - }, - "required": [ - "name", - "namespace", - "policy_id", - "enabled" - ] - }, "output": { "title": "Output", "type": "object", diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index cd4fdc3a45593..f95d51ceb00b5 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -1839,19 +1839,7 @@ paths: content: application/json: schema: - oneOf: - - $ref: '#/components/schemas/simplified_package_policy' - - deprecated: true - allOf: - - $ref: '#/components/schemas/new_package_policy' - - type: object - properties: - id: - type: string - - type: object - properties: - force: - type: boolean + $ref: '#/components/schemas/package_policy_request' parameters: - $ref: '#/components/parameters/kbn_xsrf' /package_policies/_bulk_get: @@ -2030,24 +2018,22 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/update_package_policy' + $ref: '#/components/schemas/package_policy_request' responses: '200': description: OK content: application/json: schema: - oneOf: - - $ref: '#/components/schemas/simplified_package_policy' - - type: object - properties: - item: - $ref: '#/components/schemas/package_policy' - sucess: - type: boolean - required: - - item - - sucess + type: object + properties: + item: + $ref: '#/components/schemas/package_policy' + sucess: + type: boolean + required: + - item + - sucess parameters: - $ref: '#/components/parameters/kbn_xsrf' delete: @@ -3515,8 +3501,8 @@ components: - api_key - active - created_at - simplified_package_policy: - title: Simplified Package Policy + package_policy_request: + title: Package Policy Request type: object properties: id: @@ -3525,24 +3511,30 @@ components: name: type: string description: Package policy name (should be unique) + example: nginx-123 description: type: string description: Package policy description + example: my description namespace: type: string description: namespace by default "default" + example: default policy_id: type: string description: Agent policy ID where that package policy will be added + example: agent-policy-id package: type: object properties: name: type: string description: Package name + example: nginx version: type: string description: Package version + example: 1.6.0 required: - name - version @@ -3556,6 +3548,19 @@ components: description: >- Package policy inputs (see integration documentation to know what inputs are available) + example: + nginx-logfile: + enabled: true + streams: + nginx.access: + enabled: true + vars: + paths: + - /var/log/nginx/access.log* + tags: + - nginx-access + preserve_original_event: false + ignore_older: 72h additionalProperties: type: object properties: @@ -3690,71 +3695,6 @@ components: type: array items: $ref: '#/components/schemas/full_agent_policy_input' - update_package_policy: - title: Update package policy - type: object - description: '' - properties: - version: - type: string - enabled: - type: boolean - package: - type: object - properties: - name: - type: string - version: - type: string - title: - type: string - required: - - name - - title - - version - namespace: - type: string - output_id: - type: string - description: Not supported output can be set at the agent policy level only - deprecated: true - inputs: - type: array - items: - type: object - properties: - type: - type: string - enabled: - type: boolean - processors: - type: array - items: - type: string - streams: - type: array - items: {} - config: - type: object - vars: - type: object - required: - - type - - enabled - - streams - policy_id: - type: string - name: - type: string - description: - type: string - force: - type: boolean - required: - - name - - namespace - - policy_id - - enabled output: title: Output type: object diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/simplified_package_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/package_policy_request.yaml similarity index 78% rename from x-pack/plugins/fleet/common/openapi/components/schemas/simplified_package_policy.yaml rename to x-pack/plugins/fleet/common/openapi/components/schemas/package_policy_request.yaml index 6ff537386f05b..4f4f5489d82a2 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/simplified_package_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/package_policy_request.yaml @@ -1,4 +1,4 @@ -title: Simplified Package Policy +title: Package Policy Request type: object properties: id: @@ -7,24 +7,30 @@ properties: name: type: string description: Package policy name (should be unique) + example: nginx-123 description: type: string description: Package policy description + example: 'my description' namespace: type: string description: namespace by default "default" + example: 'default' policy_id: type: string description: Agent policy ID where that package policy will be added + example: 'agent-policy-id' package: type: object properties: name: type: string description: Package name + example: 'nginx' version: type: string description: Package version + example: '1.6.0' required: - name - version @@ -34,6 +40,19 @@ properties: inputs: type: object description: Package policy inputs (see integration documentation to know what inputs are available) + example: + nginx-logfile: + enabled: true + streams: + nginx.access: + enabled: true + vars: + paths: + - '/var/log/nginx/access.log*' + tags: + - nginx-access + preserve_original_event: false + ignore_older: 72h additionalProperties: type: object properties: diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml index 10e4fba447bc5..ac609d2118fa4 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies.yaml @@ -45,19 +45,6 @@ post: content: application/json: schema: - oneOf: - - $ref: ../components/schemas/simplified_package_policy.yaml - # Using inputs as an array is deprecated - - deprecated: true - allOf: - - $ref: ../components/schemas/new_package_policy.yaml - - type: object - properties: - id: - type: string - - type: object - properties: - force: - type: boolean + $ref: ../components/schemas/package_policy_request.yaml parameters: - $ref: ../components/headers/kbn_xsrf.yaml diff --git a/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml b/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml index bf3e0e0a6eeff..bb4a76f1cd3df 100644 --- a/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml +++ b/x-pack/plugins/fleet/common/openapi/paths/package_policies@{package_policy_id}.yaml @@ -27,24 +27,22 @@ put: content: application/json: schema: - $ref: ../components/schemas/update_package_policy.yaml + $ref: ../components/schemas/package_policy_request.yaml responses: '200': description: OK content: application/json: schema: - oneOf: - - $ref: ../components/schemas/simplified_package_policy.yaml - - type: object - properties: - item: - $ref: ../components/schemas/package_policy.yaml - sucess: - type: boolean - required: - - item - - sucess + type: object + properties: + item: + $ref: ../components/schemas/package_policy.yaml + sucess: + type: boolean + required: + - item + - sucess parameters: - $ref: ../components/headers/kbn_xsrf.yaml delete: