From 84f8c95e5a5aac614ca9e40cd85dcc9fd687e3b0 Mon Sep 17 00:00:00 2001 From: Milton Hultgren Date: Mon, 11 Oct 2021 11:06:06 +0200 Subject: [PATCH] [Logs UI][Metrics UI] Replace usage of deprecated IndexPattern types (#107887) --- .../common/dependency_mocks/index_patterns.ts | 13 ++++++------ .../resolved_log_source_configuration.ts | 12 +++++------ .../components/expression_chart.test.tsx | 4 ++-- .../components/expression_chart.tsx | 4 ++-- .../hooks/use_metrics_explorer_chart_data.ts | 4 ++-- .../logs/log_filter/log_filter_state.ts | 5 +++-- .../containers/logs/log_source/log_source.ts | 4 ++-- .../containers/with_kuery_autocompletion.tsx | 7 ++++--- .../containers/with_source/with_source.tsx | 4 ++-- .../hooks/use_kibana_index_patterns.mock.tsx | 20 ++++++------------- .../indices_configuration_panel.stories.tsx | 3 +++ .../pages/logs/settings/validation_errors.ts | 13 ++++++------ .../infra/public/pages/metrics/index.tsx | 4 ++-- .../components/toolbars/toolbar.tsx | 4 ++-- .../metrics_explorer/components/kuery_bar.tsx | 9 +++------ .../metrics_explorer/components/toolbar.tsx | 5 +++-- .../hooks/use_metric_explorer_state.ts | 4 ++-- .../hooks/use_metrics_explorer_data.test.tsx | 4 ++-- .../hooks/use_metrics_explorer_data.ts | 4 ++-- .../pages/metrics/metrics_explorer/index.tsx | 4 ++-- x-pack/plugins/infra/public/utils/kuery.ts | 5 +++-- .../utils/logs_overview_fetches.test.ts | 1 + .../log_entries_search_strategy.test.ts | 1 + .../log_entry_search_strategy.test.ts | 1 + 24 files changed, 68 insertions(+), 71 deletions(-) diff --git a/x-pack/plugins/infra/common/dependency_mocks/index_patterns.ts b/x-pack/plugins/infra/common/dependency_mocks/index_patterns.ts index 14215c1539473..ca66b47fb5a25 100644 --- a/x-pack/plugins/infra/common/dependency_mocks/index_patterns.ts +++ b/x-pack/plugins/infra/common/dependency_mocks/index_patterns.ts @@ -10,14 +10,13 @@ import { delay } from 'rxjs/operators'; import { fieldList, FieldSpec, - IIndexPattern, - IndexPattern, - IndexPatternsContract, + DataView, + DataViewsContract, RuntimeField, } from 'src/plugins/data/common'; type IndexPatternMock = Pick< - IndexPattern, + DataView, | 'fields' | 'getComputedFields' | 'getFieldByName' @@ -27,7 +26,7 @@ type IndexPatternMock = Pick< | 'title' | 'type' >; -type IndexPatternMockSpec = Pick & { +type IndexPatternMockSpec = Pick & { fields: FieldSpec[]; }; @@ -71,8 +70,8 @@ export const createIndexPatternsMock = ( asyncDelay: number, indexPatterns: IndexPatternMock[] ): { - getIdsWithTitle: IndexPatternsContract['getIdsWithTitle']; - get: (...args: Parameters) => Promise; + getIdsWithTitle: DataViewsContract['getIdsWithTitle']; + get: (...args: Parameters) => Promise; } => { return { async getIdsWithTitle(_refresh?: boolean) { diff --git a/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts b/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts index 9c41a216c7f92..b906164cfb0b3 100644 --- a/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts +++ b/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts @@ -6,7 +6,7 @@ */ import { estypes } from '@elastic/elasticsearch'; -import { IndexPattern, IndexPatternsContract } from '../../../../../src/plugins/data/common'; +import { DataView, DataViewsContract } from '../../../../../src/plugins/data/common'; import { ObjectEntries } from '../utility_types'; import { ResolveLogSourceConfigurationError } from './errors'; import { @@ -21,14 +21,14 @@ export interface ResolvedLogSourceConfiguration { timestampField: string; tiebreakerField: string; messageField: string[]; - fields: IndexPattern['fields']; + fields: DataView['fields']; runtimeMappings: estypes.MappingRuntimeFields; columns: LogSourceColumnConfiguration[]; } export const resolveLogSourceConfiguration = async ( sourceConfiguration: LogSourceConfigurationProperties, - indexPatternsService: IndexPatternsContract + indexPatternsService: DataViewsContract ): Promise => { if (sourceConfiguration.logIndices.type === 'index_name') { return await resolveLegacyReference(sourceConfiguration, indexPatternsService); @@ -39,7 +39,7 @@ export const resolveLogSourceConfiguration = async ( const resolveLegacyReference = async ( sourceConfiguration: LogSourceConfigurationProperties, - indexPatternsService: IndexPatternsContract + indexPatternsService: DataViewsContract ): Promise => { if (sourceConfiguration.logIndices.type !== 'index_name') { throw new Error('This function can only resolve legacy references'); @@ -74,7 +74,7 @@ const resolveLegacyReference = async ( const resolveKibanaIndexPatternReference = async ( sourceConfiguration: LogSourceConfigurationProperties, - indexPatternsService: IndexPatternsContract + indexPatternsService: DataViewsContract ): Promise => { if (sourceConfiguration.logIndices.type !== 'index_pattern') { throw new Error('This function can only resolve Kibana Index Pattern references'); @@ -103,7 +103,7 @@ const resolveKibanaIndexPatternReference = async ( }; // this might take other sources of runtime fields into account in the future -const resolveRuntimeMappings = (indexPattern: IndexPattern): estypes.MappingRuntimeFields => { +const resolveRuntimeMappings = (indexPattern: DataView): estypes.MappingRuntimeFields => { const { runtimeFields } = indexPattern.getComputedFields(); const runtimeMappingsFromIndexPattern = ( diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index caf8e32814fe5..5aafd9b613d99 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -9,7 +9,7 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest'; // We are using this inside a `jest.mock` call. Jest requires dynamic dependencies to be prefixed with `mock` import { coreMock as mockCoreMock } from 'src/core/public/mocks'; import { MetricExpression } from '../types'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfiguration } from '../../../../common/metrics_sources'; import React from 'react'; import { ExpressionChart } from './expression_chart'; @@ -40,7 +40,7 @@ jest.mock('../hooks/use_metrics_explorer_chart_data', () => ({ describe('ExpressionChart', () => { async function setup(expression: MetricExpression, filterQuery?: string, groupBy?: string) { - const derivedIndexPattern: IIndexPattern = { + const derivedIndexPattern: DataViewBase = { title: 'metricbeat-*', fields: [], }; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx index e5558b961ab20..b176e3907228c 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx @@ -10,7 +10,7 @@ import { Axis, Chart, niceTimeFormatter, Position, Settings } from '@elastic/cha import { first, last } from 'lodash'; import { EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfiguration } from '../../../../common/metrics_sources'; import { Color } from '../../../../common/color_palette'; import { MetricsExplorerRow, MetricsExplorerAggregation } from '../../../../common/http_api'; @@ -34,7 +34,7 @@ import { ThresholdAnnotations } from '../../common/criterion_preview_chart/thres interface Props { expression: MetricExpression; - derivedIndexPattern: IIndexPattern; + derivedIndexPattern: DataViewBase; source: MetricsSourceConfiguration | null; filterQuery?: string; groupBy?: string | string[]; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metrics_explorer_chart_data.ts b/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metrics_explorer_chart_data.ts index e3006993216ae..1ae1bacfed42e 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metrics_explorer_chart_data.ts +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metrics_explorer_chart_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { useMemo } from 'react'; import { MetricsSourceConfiguration } from '../../../../common/metrics_sources'; import { MetricExpression } from '../types'; @@ -14,7 +14,7 @@ import { useMetricsExplorerData } from '../../../pages/metrics/metrics_explorer/ export const useMetricsExplorerChartData = ( expression: MetricExpression, - derivedIndexPattern: IIndexPattern, + derivedIndexPattern: DataViewBase, source: MetricsSourceConfiguration | null, filterQuery?: string, groupBy?: string | string[] 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 d4cb7ca90541f..f4576158b9a25 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 @@ -8,7 +8,8 @@ import createContainer from 'constate'; import { useCallback, useState } from 'react'; import useDebounce from 'react-use/lib/useDebounce'; -import { esQuery, IIndexPattern, Query } from '../../../../../../../src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; +import { esQuery, Query } from '../../../../../../../src/plugins/data/public'; type ParsedQuery = ReturnType; @@ -33,7 +34,7 @@ const initialLogFilterState: ILogFilterState = { const validationDebounceTimeout = 1000; // milliseconds -export const useLogFilterState = ({ indexPattern }: { indexPattern: IIndexPattern }) => { +export const useLogFilterState = ({ indexPattern }: { indexPattern: DataViewBase }) => { const [logFilterState, setLogFilterState] = useState(initialLogFilterState); const parseQuery = useCallback( diff --git a/x-pack/plugins/infra/public/containers/logs/log_source/log_source.ts b/x-pack/plugins/infra/public/containers/logs/log_source/log_source.ts index 198d0d2efe44c..f776fc1890b95 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_source/log_source.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_source/log_source.ts @@ -8,7 +8,7 @@ import createContainer from 'constate'; import { useCallback, useMemo, useState } from 'react'; import type { HttpHandler } from 'src/core/public'; -import { IndexPatternsContract } from '../../../../../../../src/plugins/data/common'; +import { DataViewsContract } from '../../../../../../../src/plugins/data/common'; import { LogIndexField, LogSourceConfigurationPropertiesPatch, @@ -42,7 +42,7 @@ export const useLogSource = ({ }: { sourceId: string; fetch: HttpHandler; - indexPatternsService: IndexPatternsContract; + indexPatternsService: DataViewsContract; }) => { const [sourceConfiguration, setSourceConfiguration] = useState< LogSourceConfiguration | undefined diff --git a/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx b/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx index f50c629d521e5..65834d4c42b7b 100644 --- a/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx +++ b/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx @@ -6,7 +6,8 @@ */ import React from 'react'; -import { QuerySuggestion, IIndexPattern, DataPublicPluginStart } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; +import { QuerySuggestion, DataPublicPluginStart } from 'src/plugins/data/public'; import { withKibana, KibanaReactContextValue, @@ -21,7 +22,7 @@ interface WithKueryAutocompletionLifecycleProps { loadSuggestions: (expression: string, cursorPosition: number, maxSuggestions?: number) => void; suggestions: QuerySuggestion[]; }>; - indexPattern: IIndexPattern; + indexPattern: DataViewBase; } interface WithKueryAutocompletionLifecycleState { @@ -82,7 +83,7 @@ class WithKueryAutocompletionComponent extends React.Component< query: expression, selectionStart: cursorPosition, selectionEnd: cursorPosition, - indexPatterns: [indexPattern], + indexPatterns: [indexPattern as any], // How to fix this without changing the dependency? boolFilter: [], })) || []; diff --git a/x-pack/plugins/infra/public/containers/with_source/with_source.tsx b/x-pack/plugins/infra/public/containers/with_source/with_source.tsx index f3ca57a40c4c7..aa7ab18271d99 100644 --- a/x-pack/plugins/infra/public/containers/with_source/with_source.tsx +++ b/x-pack/plugins/infra/public/containers/with_source/with_source.tsx @@ -7,7 +7,7 @@ import React, { useContext } from 'react'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfigurationProperties, PartialMetricsSourceConfigurationProperties, @@ -21,7 +21,7 @@ interface WithSourceProps { create: ( sourceProperties: PartialMetricsSourceConfigurationProperties ) => Promise | undefined; - createDerivedIndexPattern: (type: 'metrics') => IIndexPattern; + createDerivedIndexPattern: (type: 'metrics') => DataViewBase; exists?: boolean; hasFailed: boolean; isLoading: boolean; diff --git a/x-pack/plugins/infra/public/hooks/use_kibana_index_patterns.mock.tsx b/x-pack/plugins/infra/public/hooks/use_kibana_index_patterns.mock.tsx index 9d3a611cff88d..65ebf46e48d02 100644 --- a/x-pack/plugins/infra/public/hooks/use_kibana_index_patterns.mock.tsx +++ b/x-pack/plugins/infra/public/hooks/use_kibana_index_patterns.mock.tsx @@ -10,23 +10,15 @@ import { from, of } from 'rxjs'; import { delay } from 'rxjs/operators'; import { CoreStart } from '../../../../../src/core/public'; import { FieldSpec } from '../../../../../src/plugins/data/common'; -import { - IIndexPattern, - IndexPattern, - IndexPatternField, - IndexPatternsContract, -} from '../../../../../src/plugins/data/public'; +import { DataView, DataViewField, DataViewsContract } from '../../../../../src/plugins/data/common'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; import { Pick2 } from '../../common/utility_types'; type MockIndexPattern = Pick< - IndexPattern, + DataView, 'id' | 'title' | 'type' | 'getTimeField' | 'isTimeBased' | 'getFieldByName' | 'getComputedFields' >; -export type MockIndexPatternSpec = Pick< - IIndexPattern, - 'id' | 'title' | 'type' | 'timeFieldName' -> & { +export type MockIndexPatternSpec = Pick & { fields: FieldSpec[]; }; @@ -59,8 +51,8 @@ export const createIndexPatternsMock = ( asyncDelay: number, indexPatterns: MockIndexPattern[] ): { - getIdsWithTitle: IndexPatternsContract['getIdsWithTitle']; - get: (...args: Parameters) => Promise; + getIdsWithTitle: DataViewsContract['getIdsWithTitle']; + get: (...args: Parameters) => Promise; } => { return { async getIdsWithTitle(_refresh?: boolean) { @@ -85,7 +77,7 @@ export const createIndexPatternMock = ({ fields, timeFieldName, }: MockIndexPatternSpec): MockIndexPattern => { - const indexPatternFields = fields.map((fieldSpec) => new IndexPatternField(fieldSpec)); + const indexPatternFields = fields.map((fieldSpec) => new DataViewField(fieldSpec)); return { id, diff --git a/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_panel.stories.tsx b/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_panel.stories.tsx index 8cc9f5b4357ef..546bb9aab0f33 100644 --- a/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_panel.stories.tsx +++ b/x-pack/plugins/infra/public/pages/logs/settings/indices_configuration_panel.stories.tsx @@ -131,6 +131,7 @@ const defaultArgs: IndicesConfigurationPanelStoryArgs = { id: 'INDEX_PATTERN_A', title: 'pattern-a-*', timeFieldName: '@timestamp', + type: undefined, fields: [ { name: '@timestamp', @@ -149,6 +150,8 @@ const defaultArgs: IndicesConfigurationPanelStoryArgs = { { id: 'INDEX_PATTERN_B', title: 'pattern-b-*', + timeFieldName: '@timestamp', + type: undefined, fields: [], }, ], diff --git a/x-pack/plugins/infra/public/pages/logs/settings/validation_errors.ts b/x-pack/plugins/infra/public/pages/logs/settings/validation_errors.ts index 81b9297f8a70b..91635fff43f6e 100644 --- a/x-pack/plugins/infra/public/pages/logs/settings/validation_errors.ts +++ b/x-pack/plugins/infra/public/pages/logs/settings/validation_errors.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { IndexPattern, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; +import { DataView } from '../../../../../../../src/plugins/data/common'; +import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; export interface GenericValidationError { type: 'generic'; @@ -67,7 +68,7 @@ export const validateStringNotEmpty = (fieldName: string, value: string): FormVa export const validateColumnListNotEmpty = (columns: unknown[]): FormValidationError[] => columns.length <= 0 ? [{ type: 'empty_column_list' }] : []; -export const validateIndexPattern = (indexPattern: IndexPattern): FormValidationError[] => { +export const validateIndexPattern = (indexPattern: DataView): FormValidationError[] => { return [ ...validateIndexPatternIsTimeBased(indexPattern), ...validateIndexPatternHasStringMessageField(indexPattern), @@ -75,9 +76,7 @@ export const validateIndexPattern = (indexPattern: IndexPattern): FormValidation ]; }; -export const validateIndexPatternIsTimeBased = ( - indexPattern: IndexPattern -): FormValidationError[] => +export const validateIndexPatternIsTimeBased = (indexPattern: DataView): FormValidationError[] => indexPattern.isTimeBased() ? [] : [ @@ -88,7 +87,7 @@ export const validateIndexPatternIsTimeBased = ( ]; export const validateIndexPatternHasStringMessageField = ( - indexPattern: IndexPattern + indexPattern: DataView ): FormValidationError[] => { const messageField = indexPattern.getFieldByName('message'); @@ -111,7 +110,7 @@ export const validateIndexPatternHasStringMessageField = ( } }; -export const validateIndexPatternIsntRollup = (indexPattern: IndexPattern): FormValidationError[] => +export const validateIndexPatternIsntRollup = (indexPattern: DataView): FormValidationError[] => indexPattern.type != null ? [ { diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index d4845a4dd9e44..ae375dc504e7a 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -11,7 +11,7 @@ import React, { useContext } from 'react'; import { Route, RouteComponentProps, Switch } from 'react-router-dom'; import { EuiErrorBoundary, EuiHeaderLinks, EuiHeaderLink } from '@elastic/eui'; -import { IIndexPattern } from 'src/plugins/data/common'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfigurationProperties } from '../../../common/metrics_sources'; import { DocumentTitle } from '../../components/document_title'; import { HelpCenterContent } from '../../components/help_center_content'; @@ -141,7 +141,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { const PageContent = (props: { configuration: MetricsSourceConfigurationProperties; - createDerivedIndexPattern: (type: 'metrics') => IIndexPattern; + createDerivedIndexPattern: (type: 'metrics') => DataViewBase; }) => { const { createDerivedIndexPattern, configuration } = props; const { options } = useContext(MetricsExplorerOptionsContainer.Context); diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx index 1c79807f139c3..14f4177798be8 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx @@ -7,6 +7,7 @@ import React, { FunctionComponent } from 'react'; import { EuiFlexItem } from '@elastic/eui'; +import { DataViewBase } from '@kbn/es-query'; import { useSourceContext } from '../../../../../containers/metrics_source'; import { SnapshotMetricInput, @@ -18,13 +19,12 @@ import { findToolbar } from '../../../../../../common/inventory_models/toolbars' import { ToolbarWrapper } from './toolbar_wrapper'; import { InfraGroupByOptions } from '../../../../../lib/lib'; -import { IIndexPattern } from '../../../../../../../../../src/plugins/data/public'; import { InventoryItemType } from '../../../../../../common/inventory_models/types'; import { WaffleOptionsState, WaffleSortOption } from '../../hooks/use_waffle_options'; import { useInventoryMeta } from '../../hooks/use_inventory_meta'; export interface ToolbarProps extends Omit { - createDerivedIndexPattern: (type: 'metrics') => IIndexPattern; + createDerivedIndexPattern: (type: 'metrics') => DataViewBase; changeMetric: (payload: SnapshotMetricInput) => void; changeGroupBy: (payload: SnapshotGroupBy) => void; changeCustomOptions: (payload: InfraGroupByOptions[]) => void; diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx index cf201c9a57f7c..2be5f14005b26 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx @@ -8,13 +8,10 @@ import { i18n } from '@kbn/i18n'; import React, { useEffect, useState } from 'react'; +import { DataViewBase } from '@kbn/es-query'; import { WithKueryAutocompletion } from '../../../../containers/with_kuery_autocompletion'; import { AutocompleteField } from '../../../../components/autocomplete_field'; -import { - esKuery, - IIndexPattern, - QuerySuggestion, -} from '../../../../../../../../src/plugins/data/public'; +import { esKuery, QuerySuggestion } from '../../../../../../../../src/plugins/data/public'; type LoadSuggestionsFn = ( e: string, @@ -25,7 +22,7 @@ type LoadSuggestionsFn = ( export type CurryLoadSuggestionsType = (loadSuggestions: LoadSuggestionsFn) => LoadSuggestionsFn; interface Props { - derivedIndexPattern: IIndexPattern; + derivedIndexPattern: DataViewBase; onSubmit: (query: string) => void; onChange?: (query: string) => void; value?: string | null; diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx index 64da554dee690..01b2d129a1f9e 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx @@ -8,7 +8,8 @@ import { EuiFlexGroup, EuiFlexItem, EuiSuperDatePicker, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { IIndexPattern, UI_SETTINGS } from '../../../../../../../../src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; +import { UI_SETTINGS } from '../../../../../../../../src/plugins/data/public'; import { MetricsExplorerMetric, MetricsExplorerAggregation, @@ -27,7 +28,7 @@ import { useKibanaUiSetting } from '../../../../utils/use_kibana_ui_setting'; import { mapKibanaQuickRangesToDatePickerRanges } from '../../../../utils/map_timepicker_quickranges_to_datepicker_ranges'; interface Props { - derivedIndexPattern: IIndexPattern; + derivedIndexPattern: DataViewBase; timeRange: MetricsExplorerTimeOptions; options: MetricsExplorerOptions; chartOptions: MetricsExplorerChartOptions; diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts index a304c81ca1298..39eb7c928997b 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts @@ -6,7 +6,7 @@ */ import { useState, useCallback, useContext } from 'react'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfigurationProperties } from '../../../../../common/metrics_sources'; import { MetricsExplorerMetric, @@ -29,7 +29,7 @@ export interface MetricExplorerViewState { export const useMetricsExplorerState = ( source: MetricsSourceConfigurationProperties, - derivedIndexPattern: IIndexPattern, + derivedIndexPattern: DataViewBase, shouldLoadImmediately = true ) => { const [refreshSignal, setRefreshSignal] = useState(0); diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx index 9a5e5fcf39ce4..0f903e4c4553a 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx @@ -20,7 +20,7 @@ import { createSeries, } from '../../../../utils/fixtures/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions } from './use_metrics_explorer_options'; -import { IIndexPattern } from '../../../../../../../../src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { HttpHandler } from 'kibana/public'; import { MetricsSourceConfigurationProperties } from '../../../../../common/metrics_sources'; @@ -39,7 +39,7 @@ const renderUseMetricsExplorerDataHook = () => { (props: { options: MetricsExplorerOptions; source: MetricsSourceConfigurationProperties | undefined; - derivedIndexPattern: IIndexPattern; + derivedIndexPattern: DataViewBase; timeRange: MetricsExplorerTimeOptions; afterKey: string | null | Record; signal: any; diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts index 95f98e172541a..6b7e98912fd49 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts @@ -8,7 +8,7 @@ import DateMath from '@elastic/datemath'; import { isEqual } from 'lodash'; import { useEffect, useState } from 'react'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfigurationProperties } from '../../../../../common/metrics_sources'; import { MetricsExplorerResponse, @@ -27,7 +27,7 @@ function isSameOptions(current: MetricsExplorerOptions, next: MetricsExplorerOpt export function useMetricsExplorerData( options: MetricsExplorerOptions, source: MetricsSourceConfigurationProperties | undefined, - derivedIndexPattern: IIndexPattern, + derivedIndexPattern: DataViewBase, timerange: MetricsExplorerTimeOptions, afterKey: string | null | Record, signal: any, diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx index f2345b0b8e020..dabf5db9afe92 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx @@ -8,7 +8,7 @@ import { EuiErrorBoundary } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useEffect, useContext } from 'react'; -import { IIndexPattern } from 'src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; import { MetricsSourceConfigurationProperties } from '../../../../common/metrics_sources'; import { useTrackPageview } from '../../../../../observability/public'; import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; @@ -25,7 +25,7 @@ import { SavedViewsToolbarControls } from '../../../components/saved_views/toolb interface MetricsExplorerPageProps { source: MetricsSourceConfigurationProperties; - derivedIndexPattern: IIndexPattern; + derivedIndexPattern: DataViewBase; } export const MetricsExplorerPage = ({ source, derivedIndexPattern }: MetricsExplorerPageProps) => { diff --git a/x-pack/plugins/infra/public/utils/kuery.ts b/x-pack/plugins/infra/public/utils/kuery.ts index 19706d7664c22..c7528b237cce5 100644 --- a/x-pack/plugins/infra/public/utils/kuery.ts +++ b/x-pack/plugins/infra/public/utils/kuery.ts @@ -5,11 +5,12 @@ * 2.0. */ -import { esKuery, IIndexPattern } from '../../../../../src/plugins/data/public'; +import { DataViewBase } from '@kbn/es-query'; +import { esKuery } from '../../../../../src/plugins/data/public'; export const convertKueryToElasticSearchQuery = ( kueryExpression: string, - indexPattern: IIndexPattern + indexPattern: DataViewBase ) => { try { return kueryExpression diff --git a/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts b/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts index 6dfb400567717..4fcb83fd02754 100644 --- a/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts +++ b/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts @@ -48,6 +48,7 @@ function setup() { id: 'test-index-pattern', title: 'log-indices-*', timeFieldName: '@timestamp', + type: undefined, fields: [ { name: 'event.dataset', diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts index 876aad4ef8d02..85a1b95cf70aa 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts @@ -342,6 +342,7 @@ const createDataPluginMock = (esSearchStrategyMock: ISearchStrategy): any => ({ id: 'test-index-pattern', title: 'log-indices-*', timeFieldName: '@timestamp', + type: undefined, fields: [ { name: 'event.dataset', diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts index 88c9d956dbe0a..ec3d4aa52a6b5 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts @@ -297,6 +297,7 @@ const createDataPluginMock = (esSearchStrategyMock: ISearchStrategy): any => ({ id: 'test-index-pattern', title: 'log-indices-*', timeFieldName: '@timestamp', + type: undefined, fields: [ { name: 'event.dataset',