diff --git a/test/functional/services/selectable.ts b/test/functional/services/selectable.ts index cab972e9620c0..2acf76f379363 100644 --- a/test/functional/services/selectable.ts +++ b/test/functional/services/selectable.ts @@ -50,7 +50,7 @@ export class SelectableService extends FtrService { `selectableBodyTestSubjectId: ${selectableBodyTestSubjectId}, textsToSelect: ${textsToSelect}` ); - await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId); + await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId); const selectableBodyContainer = await this.testSubjects.find(selectableBodyTestSubjectId); const listContainer = await selectableBodyContainer.findByClassName('euiSelectableList'); @@ -92,7 +92,7 @@ export class SelectableService extends FtrService { searchText: string, optionText: string ) { - await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId); + await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId); // Clear and set search text await this.testSubjects.setValue(searchInputTestSubjectId, searchText, { @@ -107,16 +107,15 @@ export class SelectableService extends FtrService { ]); } - private async openIfClosed(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) { + private async ensureOpened(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) { // Open the selectable if `selectableBodyTestSubjectId` doesn't exist - const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId, { - timeout: 500, - }); + const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId); if (!isSelectableOpen) { await this.testSubjects.click(buttonTestSubjectId); - await this.common.sleep(500); } + + await this.testSubjects.existOrFail(selectableBodyTestSubjectId); } } diff --git a/x-pack/plugins/fleet/server/constants/fleet_es_assets.ts b/x-pack/plugins/fleet/server/constants/fleet_es_assets.ts index 61044ee7a758e..448df5e5e683b 100644 --- a/x-pack/plugins/fleet/server/constants/fleet_es_assets.ts +++ b/x-pack/plugins/fleet/server/constants/fleet_es_assets.ts @@ -82,11 +82,13 @@ export const FLEET_COMPONENT_TEMPLATES = [ ]; export const STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS = `logs@settings`; +export const STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS = `logs@mappings`; export const STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS = `metrics@settings`; export const STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS = `metrics@tsdb-settings`; export const STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS = 'ecs@mappings'; export const STACK_COMPONENT_TEMPLATES = [ + STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS, STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS, STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS, diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts index 82ee4a52b65a3..0ea833172e028 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts @@ -14,6 +14,8 @@ import { elasticsearchServiceMock } from '@kbn/core/server/mocks'; import { errors } from '@elastic/elasticsearch'; +import { STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS } from '../../../../constants/fleet_es_assets'; + import { createAppContextStartContractMock } from '../../../../mocks'; import { appContextService } from '../../..'; import type { RegistryDataStream } from '../../../../types'; @@ -23,6 +25,7 @@ import { FLEET_COMPONENT_TEMPLATES, STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS, FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME, + STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS, } from '../../../../constants'; import { @@ -81,7 +84,8 @@ describe('EPM template', () => { isIndexModeTimeSeries: false, }); expect(template.composed_of).toStrictEqual([ - 'logs@settings', + STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, + STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS, ...composedOfTemplates, STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS, ...FLEET_COMPONENT_TEMPLATES_NAMES, @@ -126,7 +130,8 @@ describe('EPM template', () => { isIndexModeTimeSeries: false, }); expect(template.composed_of).toStrictEqual([ - 'logs@settings', + STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, + STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS, ...composedOfTemplates, STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS, FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME, @@ -146,7 +151,8 @@ describe('EPM template', () => { isIndexModeTimeSeries: false, }); expect(template.composed_of).toStrictEqual([ - 'logs@settings', + STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, + STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS, STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS, ...FLEET_COMPONENT_TEMPLATES_NAMES, ]); diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts index 0cc3816e839a9..c4984b1195475 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts @@ -14,6 +14,8 @@ import type { import pMap from 'p-map'; import { isResponseError } from '@kbn/es-errors'; +import { STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS } from '../../../../constants/fleet_es_assets'; + import type { Field, Fields } from '../../fields/field'; import type { RegistryDataStream, @@ -135,7 +137,7 @@ const getBaseEsComponents = (type: string, isIndexModeTimeSeries: boolean): stri return [STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS]; } else if (type === 'logs') { - return [STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS]; + return [STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS]; } return []; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/fields.ts b/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/fields.ts deleted file mode 100644 index d02ee39e8383b..0000000000000 --- a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/fields.ts +++ /dev/null @@ -1,22 +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 * as yaml from 'js-yaml'; - -export const createBaseFields = () => { - const fields = [ - { name: 'data_stream.type', type: 'constant_keyword', description: 'Data stream type.' }, - { name: 'data_stream.dataset', type: 'constant_keyword', description: 'Data stream dataset.' }, - { - name: 'data_stream.namespace', - type: 'constant_keyword', - description: 'Data stream namespace.', - }, - { name: '@timestamp', type: 'date', description: 'Event timestamp.' }, - ]; - return yaml.dump(fields); -}; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/index.ts b/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/index.ts index 76a7a6f6a089f..60f29536a53a6 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/dataset/index.ts @@ -5,6 +5,5 @@ * 2.0. */ -export * from './fields'; export * from './manifest'; export * from './utils'; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/generate.ts b/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/generate.ts index f32e1983a274e..08b08e6bb3982 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/generate.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/custom_integrations/assets/generate.ts @@ -11,7 +11,7 @@ import { pkgToPkgKey } from '../../../registry'; import type { CustomPackageDatasetConfiguration } from '../../install'; -import { createBaseFields, createDatasetManifest } from './dataset'; +import { createDatasetManifest } from './dataset'; import { createDefaultPipeline } from './dataset/ingest_pipeline'; import { createManifest } from './manifest'; @@ -38,13 +38,6 @@ export const createAssets = (assetOptions: AssetOptions) => { }, // NOTE: buildDefaultSettings() will add a reference to the global ILM policy when // building the index template based on the fields assets. - { - path: `${pkgToPkgKey({ - name, - version, - })}/data_stream/${datasetName}/fields/base-fields.yml`, - content: Buffer.from(createBaseFields()), - }, { path: `${pkgToPkgKey({ name, diff --git a/x-pack/plugins/observability_solution/observability/public/hooks/use_fetch_data_views.ts b/x-pack/plugins/observability_solution/observability/public/hooks/use_fetch_data_views.ts index 2d7602431266f..3e19bb73d8f02 100644 --- a/x-pack/plugins/observability_solution/observability/public/hooks/use_fetch_data_views.ts +++ b/x-pack/plugins/observability_solution/observability/public/hooks/use_fetch_data_views.ts @@ -16,10 +16,10 @@ export interface UseFetchDataViewsResponse { data: DataViewListItem[] | undefined; } -export function useFetchDataViews(): UseFetchDataViewsResponse { +export function useFetchDataViews() { const { dataViews } = useKibana().services; - const { isLoading, isError, isSuccess, data } = useQuery({ + const { isLoading, isError, isSuccess, data, refetch } = useQuery({ queryKey: ['fetchDataViewsList'], queryFn: async () => { return dataViews.getIdsWithTitle(); @@ -29,5 +29,5 @@ export function useFetchDataViews(): UseFetchDataViewsResponse { refetchOnWindowFocus: false, }); - return { isLoading, isError, isSuccess, data }; + return { isLoading, isError, isSuccess, data, refetch }; } diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/components/custom_common/index_selection.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/components/custom_common/index_selection.tsx index 880c15e6a67be..fe023cd859549 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/components/custom_common/index_selection.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/components/custom_common/index_selection.tsx @@ -19,7 +19,7 @@ export function IndexSelection() { const { control, getFieldState, setValue, watch } = useFormContext(); const { dataViews: dataViewsService } = useKibana().services; - const { isLoading: isDataViewsLoading, data: dataViews = [] } = useFetchDataViews(); + const { isLoading: isDataViewsLoading, data: dataViews = [], refetch } = useFetchDataViews(); const { dataViewEditor } = useKibana().services; @@ -100,7 +100,8 @@ export function IndexSelection() { setAdHocDataViews([...adHocDataViews, dataView]); field.onChange(dataView.getIndexPattern()); } else { - field.onChange(getDataViewPatternById(dataView.id)); + refetch(); + field.onChange(dataView.getIndexPattern()); } if (dataView.timeFieldName) { setValue('indicator.params.timestampField', dataView.timeFieldName); diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts index 61d71b63f40f5..13cfbc05d61d0 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts @@ -57,6 +57,7 @@ export default function (providerContext: FtrProviderContext) { // the index template composed_of has the correct component templates in the correct order const indexTemplate = indexTemplateResponse.index_templates[0].index_template; expect(indexTemplate.composed_of).to.eql([ + `logs@mappings`, `logs@settings`, `${templateName}@package`, `${templateName}@custom`,