diff --git a/x-pack/plugins/infra/common/log_views/resolved_log_view.mock.ts b/x-pack/plugins/infra/common/log_views/resolved_log_view.mock.ts index a910205fc8366..268b2f692f62a 100644 --- a/x-pack/plugins/infra/common/log_views/resolved_log_view.mock.ts +++ b/x-pack/plugins/infra/common/log_views/resolved_log_view.mock.ts @@ -10,13 +10,6 @@ import { createStubDataView } from '@kbn/data-views-plugin/common/stubs'; import { defaultLogViewsStaticConfig } from './defaults'; import { ResolvedLogView, resolveLogView } from './resolved_log_view'; import { LogViewAttributes } from './types'; -import { DataView } from '@kbn/data-views-plugin/common'; - -const dataViewMock = { - id: 'log-view-data-view-mock', - title: 'log-view-data-view-mock-title', - fields: [], -} as unknown as DataView; export const createResolvedLogViewMock = ( resolvedLogViewOverrides: Partial = {} @@ -48,7 +41,6 @@ export const createResolvedLogViewMock = ( messageColumn: { id: 'MESSAGE_COLUMN_ID' }, }, ], - dataViewReference: dataViewMock, ...resolvedLogViewOverrides, }); diff --git a/x-pack/plugins/infra/common/log_views/resolved_log_view.ts b/x-pack/plugins/infra/common/log_views/resolved_log_view.ts index 329dc948a2da0..d7e155172a57e 100644 --- a/x-pack/plugins/infra/common/log_views/resolved_log_view.ts +++ b/x-pack/plugins/infra/common/log_views/resolved_log_view.ts @@ -23,7 +23,6 @@ export interface ResolvedLogView { fields: ResolvedLogViewField[]; runtimeMappings: estypes.MappingRuntimeFields; columns: LogViewColumnConfiguration[]; - dataViewReference: DataView; } export const resolveLogView = async ( @@ -61,12 +60,6 @@ const resolveLegacyReference = async ( ); }); - const dataViewReference = await dataViewsService.create({ - id: '___InfraLogsLegacyLogViewReference___', - title: logViewAttributes.logIndices.indexName, - timeFieldName: TIMESTAMP_FIELD, - }); - return { indices: logViewAttributes.logIndices.indexName, timestampField: TIMESTAMP_FIELD, @@ -77,7 +70,6 @@ const resolveLegacyReference = async ( columns: logViewAttributes.logColumns, name: logViewAttributes.name, description: logViewAttributes.description, - dataViewReference, }; }; @@ -105,7 +97,6 @@ const resolveDataViewReference = async ( columns: logViewAttributes.logColumns, name: logViewAttributes.name, description: logViewAttributes.description, - dataViewReference: dataView, }; }; diff --git a/x-pack/plugins/infra/public/components/log_stream/log_stream.tsx b/x-pack/plugins/infra/public/components/log_stream/log_stream.tsx index e5aeefba983f1..2913b2cbb5ecf 100644 --- a/x-pack/plugins/infra/public/components/log_stream/log_stream.tsx +++ b/x-pack/plugins/infra/public/components/log_stream/log_stream.tsx @@ -7,11 +7,11 @@ import { buildEsQuery, Filter, Query } from '@kbn/es-query'; import { JsonValue } from '@kbn/utility-types'; +import { noop } from 'lodash'; import React, { useCallback, useEffect, useMemo } from 'react'; import { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { noop } from 'lodash'; import { LogEntryCursor } from '../../../common/log_entry'; import { defaultLogViewsStaticConfig } from '../../../common/log_views'; import { BuiltEsQuery, useLogStream } from '../../containers/logs/log_stream'; diff --git a/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts index d5c6a86d8ce75..f836c642aa0b3 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts @@ -53,7 +53,7 @@ const unsupportedLanguageError = i18n.translate( } ); -export const useLogFilterState = ({ dataView }: { dataView?: DataViewBase }) => { +export const useLogFilterState = ({ dataView }: { dataView: DataViewBase }) => { const { notifications: { toasts }, data: { diff --git a/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts b/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts index 8bef101abe666..daebfb82b4564 100644 --- a/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts +++ b/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts @@ -17,7 +17,10 @@ const defaultLogViewId = 'default'; export const createUninitializedUseLogViewMock = (logViewId: string = defaultLogViewId) => (): IUseLogView => ({ - derivedDataView: undefined, + derivedDataView: { + fields: [], + title: 'unknown', + }, hasFailedLoading: false, hasFailedLoadingLogView: false, hasFailedLoadingLogViewStatus: false, diff --git a/x-pack/plugins/infra/public/hooks/use_log_view.ts b/x-pack/plugins/infra/public/hooks/use_log_view.ts index 9dd0468d60b40..b1b8bb6e33cc9 100644 --- a/x-pack/plugins/infra/public/hooks/use_log_view.ts +++ b/x-pack/plugins/infra/public/hooks/use_log_view.ts @@ -63,9 +63,13 @@ export const useLogView = ({ [logViews] ); - const derivedDataView = useMemo(() => { - return resolvedLogView?.dataViewReference; - }, [resolvedLogView]); + const derivedDataView = useMemo( + () => ({ + fields: resolvedLogView?.fields ?? [], + title: resolvedLogView?.indices ?? 'unknown', + }), + [resolvedLogView] + ); const isLoadingLogView = loadLogViewRequest.state === 'pending'; const isResolvingLogView = resolveLogViewRequest.state === 'pending'; diff --git a/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx index cf30518f78ede..2929151a1902e 100644 --- a/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx @@ -8,6 +8,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; +import { DataView } from '@kbn/data-views-plugin/public'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { useKibanaContextForPlugin } from '../../../hooks/use_kibana'; import { LogCustomizationMenu } from '../../../components/logging/log_customization_menu'; @@ -61,7 +62,7 @@ export const LogsToolbar = () => { defaultMessage: 'Search for log entries… (e.g. host.name:host-1)', })} useDefaultBehaviors={true} - indexPatterns={derivedDataView ? [derivedDataView] : undefined} + indexPatterns={[derivedDataView as DataView]} showQueryInput={true} showQueryMenu={false} showFilterBar={false}