diff --git a/x-pack/packages/ml/aiops_components/index.ts b/x-pack/packages/ml/aiops_components/index.ts index c9ca50ad0daf..3a640c1d0cb4 100644 --- a/x-pack/packages/ml/aiops_components/index.ts +++ b/x-pack/packages/ml/aiops_components/index.ts @@ -9,7 +9,15 @@ export { DualBrush, DualBrushAnnotation } from './src/dual_brush'; export { ProgressControls } from './src/progress_controls'; export { DocumentCountChart, + DocumentCountChartWithAutoAnalysisStart, type BrushSettings, type BrushSelectionUpdateHandler, } from './src/document_count_chart'; export type { DocumentCountChartProps } from './src/document_count_chart'; +export { + useLogRateAnalysisStateContext, + LogRateAnalysisStateProvider, + type GroupTableItem, + type GroupTableItemGroup, + type TableItemAction, +} from './src/log_rate_analysis_state_provider'; diff --git a/x-pack/packages/ml/aiops_components/src/document_count_chart/document_count_chart.tsx b/x-pack/packages/ml/aiops_components/src/document_count_chart/document_count_chart.tsx index 57139ddd0a1f..02c532d18670 100644 --- a/x-pack/packages/ml/aiops_components/src/document_count_chart/document_count_chart.tsx +++ b/x-pack/packages/ml/aiops_components/src/document_count_chart/document_count_chart.tsx @@ -40,6 +40,8 @@ import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import { DualBrush, DualBrushAnnotation } from '../..'; +import { useLogRateAnalysisStateContext } from '../log_rate_analysis_state_provider'; + import { BrushBadge } from './brush_badge'; declare global { @@ -87,6 +89,11 @@ export type BrushSelectionUpdateHandler = ( logRateAnalysisType: LogRateAnalysisType ) => void; +/** + * Callback to set the autoRunAnalysis flag + */ +type SetAutoRunAnalysisFn = (isAutoRun: boolean) => void; + /** * Props for document count chart */ @@ -118,9 +125,11 @@ export interface DocumentCountChartProps { chartPointsSplitLabel: string; /** Whether or not brush has been reset */ isBrushCleared: boolean; + /** Callback to set the autoRunAnalysis flag */ + setAutoRunAnalysis?: SetAutoRunAnalysisFn; /** Timestamp for start of initial analysis */ autoAnalysisStart?: number | WindowParameters; - /** Optional style to override bar chart */ + /** Optional style to override bar chart */ barStyleAccessor?: BarStyleAccessor; /** Optional color override for the default bar color for charts */ barColorOverride?: string; @@ -181,6 +190,7 @@ export const DocumentCountChart: FC = (props) => { interval, chartPointsSplitLabel, isBrushCleared, + setAutoRunAnalysis, autoAnalysisStart, barColorOverride, barStyleAccessor, @@ -305,6 +315,17 @@ export const DocumentCountChart: FC = (props) => { windowParameters === undefined && adjustedChartPoints !== undefined ) { + if (setAutoRunAnalysis) { + const autoRun = + typeof startRange !== 'number' || + (typeof startRange === 'number' && + changePoint !== undefined && + startRange >= changePoint.startTs && + startRange <= changePoint.endTs); + + setAutoRunAnalysis(autoRun); + } + const wp = getWindowParametersForTrigger( startRange, interval, @@ -333,6 +354,7 @@ export const DocumentCountChart: FC = (props) => { timeRangeLatest, snapTimestamps, originalWindowParameters, + setAutoRunAnalysis, setWindowParameters, brushSelectionUpdateHandler, adjustedChartPoints, @@ -535,3 +557,24 @@ export const DocumentCountChart: FC = (props) => { ); }; + +/** + * Functional component that renders a `DocumentCountChart` with additional properties + * managed by the log rate analysis state. It leverages the `useLogRateAnalysisStateContext` + * to acquire state variables like `initialAnalysisStart` and functions such as + * `setAutoRunAnalysis`. These values are then passed as props to the `DocumentCountChart`. + * + * @param props - The properties passed to the DocumentCountChart component. + * @returns The DocumentCountChart component enhanced with automatic analysis start capabilities. + */ +export const DocumentCountChartWithAutoAnalysisStart: FC = (props) => { + const { initialAnalysisStart, setAutoRunAnalysis } = useLogRateAnalysisStateContext(); + + return ( + + ); +}; diff --git a/x-pack/packages/ml/aiops_components/src/document_count_chart/index.ts b/x-pack/packages/ml/aiops_components/src/document_count_chart/index.ts index 5b64acedbf5f..efde8b0a83cb 100644 --- a/x-pack/packages/ml/aiops_components/src/document_count_chart/index.ts +++ b/x-pack/packages/ml/aiops_components/src/document_count_chart/index.ts @@ -5,7 +5,10 @@ * 2.0. */ -export { DocumentCountChart } from './document_count_chart'; +export { + DocumentCountChart, + DocumentCountChartWithAutoAnalysisStart, +} from './document_count_chart'; export type { BrushSelectionUpdateHandler, BrushSettings, diff --git a/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/index.ts b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/index.ts new file mode 100644 index 000000000000..18453665cb4f --- /dev/null +++ b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/index.ts @@ -0,0 +1,12 @@ +/* + * 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 { + useLogRateAnalysisStateContext, + LogRateAnalysisStateProvider, +} from './log_rate_analysis_state_provider'; +export type { GroupTableItem, GroupTableItemGroup, TableItemAction } from './types'; diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider.tsx b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/log_rate_analysis_state_provider.tsx similarity index 50% rename from x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider.tsx rename to x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/log_rate_analysis_state_provider.tsx index a7b3398e4e7c..f3aa55bdce77 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider.tsx +++ b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/log_rate_analysis_state_provider.tsx @@ -16,13 +16,19 @@ import React, { } from 'react'; import type { SignificantItem } from '@kbn/ml-agg-utils'; +import type { WindowParameters } from '@kbn/aiops-log-rate-analysis'; import type { GroupTableItem } from './types'; +type InitialAnalysisStart = number | WindowParameters | undefined; type SignificantItemOrNull = SignificantItem | null; type GroupOrNull = GroupTableItem | null; -interface LogRateAnalysisResultsTableRow { +interface LogRateAnalysisState { + autoRunAnalysis: boolean; + setAutoRunAnalysis: Dispatch>; + initialAnalysisStart: InitialAnalysisStart; + setInitialAnalysisStart: Dispatch>; pinnedSignificantItem: SignificantItemOrNull; setPinnedSignificantItem: Dispatch>; pinnedGroup: GroupOrNull; @@ -36,12 +42,38 @@ interface LogRateAnalysisResultsTableRow { clearAllRowState: () => void; } -export const logRateAnalysisResultsTableRowContext = createContext< - LogRateAnalysisResultsTableRow | undefined ->(undefined); +const LogRateAnalysisStateContext = createContext(undefined); -export const LogRateAnalysisResultsTableRowStateProvider: FC = ({ children }) => { - // State that will be shared with all components +/** + * Props for LogRateAnalysisStateProvider. + */ +interface LogRateAnalysisStateProviderProps { + /** The parameters to be used to trigger an analysis. */ + initialAnalysisStart?: InitialAnalysisStart; +} + +/** + * Context provider component that manages and provides global state for Log Rate Analysis. + * This provider handles several pieces of state important for controlling and displaying + * log rate analysis data, such as the control of automatic analysis runs, and the management + * of both pinned and selected significant items and groups. + * + * The state includes mechanisms for setting initial analysis parameters, toggling analysis, + * and managing the current selection and pinned state of significant items and groups. + * + * @param props - Props object containing initial settings for the analysis, + * including children components to be wrapped by the Provider. + * @returns A context provider wrapping children with access to log rate analysis state. + */ +export const LogRateAnalysisStateProvider: FC = (props) => { + const { children, initialAnalysisStart: incomingInitialAnalysisStart } = props; + + const [autoRunAnalysis, setAutoRunAnalysis] = useState(true); + const [initialAnalysisStart, setInitialAnalysisStart] = useState< + number | WindowParameters | undefined + >(incomingInitialAnalysisStart); + + // Row state that will be shared with all components const [pinnedSignificantItem, setPinnedSignificantItem] = useState(null); const [pinnedGroup, setPinnedGroup] = useState(null); const [selectedSignificantItem, setSelectedSignificantItem] = @@ -66,8 +98,12 @@ export const LogRateAnalysisResultsTableRowStateProvider: FC = ({ children }) => } }, [selectedGroup, pinnedGroup]); - const contextValue: LogRateAnalysisResultsTableRow = useMemo( + const contextValue: LogRateAnalysisState = useMemo( () => ({ + autoRunAnalysis, + setAutoRunAnalysis, + initialAnalysisStart, + setInitialAnalysisStart, pinnedSignificantItem, setPinnedSignificantItem, pinnedGroup, @@ -86,6 +122,10 @@ export const LogRateAnalysisResultsTableRowStateProvider: FC = ({ children }) => }, }), [ + autoRunAnalysis, + setAutoRunAnalysis, + initialAnalysisStart, + setInitialAnalysisStart, pinnedSignificantItem, setPinnedSignificantItem, pinnedGroup, @@ -101,19 +141,26 @@ export const LogRateAnalysisResultsTableRowStateProvider: FC = ({ children }) => return ( // Provider managing the state - + {children} - + ); }; -export const useLogRateAnalysisResultsTableRowContext = () => { - const logRateAnalysisResultsTableRow = useContext(logRateAnalysisResultsTableRowContext); +/** + * Custom hook for accessing the state of log rate analysis from the LogRateAnalysisStateContext. + * This hook must be used within a component that is a descendant of the LogRateAnalysisStateContext provider. + * + * @returns The current state of the log rate analysis. + * @throws Throws an error if the hook is used outside of its Provider context. + */ +export const useLogRateAnalysisStateContext = () => { + const logRateAnalysisState = useContext(LogRateAnalysisStateContext); // If `undefined`, throw an error. - if (logRateAnalysisResultsTableRow === undefined) { - throw new Error('useLogRateAnalysisResultsTableRowContext was used outside of its Provider'); + if (logRateAnalysisState === undefined) { + throw new Error('useLogRateAnalysisStateContext was used outside of its Provider'); } - return logRateAnalysisResultsTableRow; + return logRateAnalysisState; }; diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/types.ts b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/types.ts similarity index 59% rename from x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/types.ts rename to x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/types.ts index 400e4534b54f..4c4013e3d486 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/types.ts +++ b/x-pack/packages/ml/aiops_components/src/log_rate_analysis_state_provider/types.ts @@ -9,20 +9,36 @@ import type { EuiTableActionsColumnType } from '@elastic/eui'; import type { SignificantItem, SignificantItemGroupItem } from '@kbn/ml-agg-utils'; +/** + * Type for defining attributes picked from + * SignificantItemGroupItem used in the grouped table. + */ export type GroupTableItemGroup = Pick< SignificantItemGroupItem, 'key' | 'type' | 'fieldName' | 'fieldValue' | 'docCount' | 'pValue' | 'duplicate' >; +/** + * Represents a single item in the group table. + */ export interface GroupTableItem { + /** Unique identifier for the group table item. */ id: string; + /** Document count associated with the item. */ docCount: number; + /** Statistical p-value indicating the significance of the item, nullable. */ pValue: number | null; + /** Count of unique items within the group. */ uniqueItemsCount: number; + /** Array of items within the group, sorted by uniqueness. */ groupItemsSortedByUniqueness: GroupTableItemGroup[]; + /** Histogram data for the significant item. */ histogram: SignificantItem['histogram']; } +/** + * Type for action columns in a table that involves SignificantItem or GroupTableItem. + */ export type TableItemAction = EuiTableActionsColumnType< SignificantItem | GroupTableItem >['actions'][number]; diff --git a/x-pack/packages/ml/aiops_components/tsconfig.json b/x-pack/packages/ml/aiops_components/tsconfig.json index 3fba5d38f9fc..23cf9e9d60d4 100644 --- a/x-pack/packages/ml/aiops_components/tsconfig.json +++ b/x-pack/packages/ml/aiops_components/tsconfig.json @@ -27,6 +27,7 @@ "@kbn/field-formats-plugin", "@kbn/visualization-utils", "@kbn/aiops-log-rate-analysis", + "@kbn/ml-agg-utils", ], "exclude": [ "target/**/*", diff --git a/x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts b/x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts index 06a5e01a2caf..888a4802e6a5 100644 --- a/x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts +++ b/x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts @@ -33,8 +33,14 @@ export const journey = new Journey({ await page.waitForSelector(subj('aiopsNoWindowParametersEmptyPrompt')); }) .step('Run AIOps Log Rate Analysis', async ({ page }) => { - // Select the chart and click in the area where the spike is located to trigger log rate analysis. + // Select the chart and click in the area where the spike is located. const chart = await page.locator(subj('aiopsDocumentCountChart')); await chart.click({ position: { x: 710, y: 50 } }); + + // Click the "Run analysis" button. + await page.waitForSelector(subj('aiopsLogRateAnalysisNoAutoRunContentRunAnalysisButton')); + await page.click(subj('aiopsLogRateAnalysisNoAutoRunContentRunAnalysisButton')); + + // Wait for the analysis to complete. await page.waitForSelector(subj('aiopsAnalysisComplete'), { timeout: 120000 }); }); diff --git a/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.test.ts b/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.test.ts index bdc1336fc944..6ab69bf7ccd1 100644 --- a/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.test.ts +++ b/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.test.ts @@ -6,8 +6,7 @@ */ import type { SignificantItem } from '@kbn/ml-agg-utils'; - -import type { GroupTableItem } from '../../components/log_rate_analysis_results_table/types'; +import type { GroupTableItem } from '@kbn/aiops-components'; import { buildExtendedBaseFilterCriteria } from './build_extended_base_filter_criteria'; diff --git a/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.ts b/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.ts index 91709b9bd91a..9d77f68cfa15 100644 --- a/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.ts +++ b/x-pack/plugins/aiops/public/application/utils/build_extended_base_filter_criteria.ts @@ -14,8 +14,7 @@ import type { Query } from '@kbn/es-query'; import { type SignificantItem, SIGNIFICANT_ITEM_TYPE } from '@kbn/ml-agg-utils'; import { buildBaseFilterCriteria } from '@kbn/ml-query-utils'; import { getCategoryQuery } from '@kbn/aiops-log-pattern-analysis/get_category_query'; - -import type { GroupTableItem } from '../../components/log_rate_analysis_results_table/types'; +import type { GroupTableItem } from '@kbn/aiops-components'; /* * Contains utility functions for building and processing queries. diff --git a/x-pack/plugins/aiops/public/components/document_count_content/document_count_content/document_count_content.tsx b/x-pack/plugins/aiops/public/components/document_count_content/document_count_content/document_count_content.tsx index 3ccf2bbbbfd2..6a13d705cc91 100644 --- a/x-pack/plugins/aiops/public/components/document_count_content/document_count_content/document_count_content.tsx +++ b/x-pack/plugins/aiops/public/components/document_count_content/document_count_content/document_count_content.tsx @@ -14,7 +14,10 @@ import type { } from '@elastic/charts/dist/chart_types/xy_chart/utils/specs'; import type { LogRateHistogramItem, WindowParameters } from '@kbn/aiops-log-rate-analysis'; -import { DocumentCountChart, type BrushSelectionUpdateHandler } from '@kbn/aiops-components'; +import { + DocumentCountChartWithAutoAnalysisStart, + type BrushSelectionUpdateHandler, +} from '@kbn/aiops-components'; import { useAiopsAppContext } from '../../../hooks/use_aiops_app_context'; import type { DocumentCountStats } from '../../../get_document_stats'; @@ -29,13 +32,11 @@ export interface DocumentCountContentProps { isBrushCleared: boolean; totalCount: number; sampleProbability: number; - initialAnalysisStart?: number | WindowParameters; /** Optional color override for the default bar color for charts */ barColorOverride?: string; /** Optional color override for the highlighted bar color for charts */ barHighlightColorOverride?: string; windowParameters?: WindowParameters; - incomingInitialAnalysisStart?: number | WindowParameters; baselineLabel?: string; deviationLabel?: string; barStyleAccessor?: BarStyleAccessor; @@ -51,11 +52,9 @@ export const DocumentCountContent: FC = ({ isBrushCleared, totalCount, sampleProbability, - initialAnalysisStart, barColorOverride, barHighlightColorOverride, windowParameters, - incomingInitialAnalysisStart, ...docCountChartProps }) => { const { data, uiSettings, fieldFormats, charts } = useAiopsAppContext(); @@ -100,7 +99,7 @@ export const DocumentCountContent: FC = ({ {documentCountStats.interval !== undefined && ( - = ({ interval={documentCountStats.interval} chartPointsSplitLabel={documentCountStatsSplitLabel} isBrushCleared={isBrushCleared} - autoAnalysisStart={initialAnalysisStart} barColorOverride={barColorOverride} barHighlightColorOverride={barHighlightColorOverride} changePoint={documentCountStats.changePoint} diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx index 7de8b5f91d61..ca06d3c7c9b3 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx @@ -17,13 +17,12 @@ import { Storage } from '@kbn/kibana-utils-plugin/public'; import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; +import { LogRateAnalysisStateProvider } from '@kbn/aiops-components'; import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context'; import { AiopsAppContext } from '../../hooks/use_aiops_app_context'; import { DataSourceContext } from '../../hooks/use_data_source'; import { AIOPS_STORAGE_KEYS } from '../../types/storage'; -import { LogRateAnalysisResultsTableRowStateProvider } from '../log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider'; - import { LogRateAnalysisPage } from './log_rate_analysis_page'; import { timeSeriesDataViewWarning } from '../../application/utils/time_series_dataview_check'; @@ -70,13 +69,13 @@ export const LogRateAnalysisAppState: FC = ({ - + - + diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx index abcffc3ebe86..b244cbc324d1 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx @@ -26,6 +26,7 @@ import { type WindowParameters, } from '@kbn/aiops-log-rate-analysis'; import type { SignificantItem } from '@kbn/ml-agg-utils'; +import { useLogRateAnalysisStateContext, type GroupTableItem } from '@kbn/aiops-components'; import { useData } from '../../../hooks/use_data'; @@ -34,8 +35,6 @@ import { LogRateAnalysisResults, type LogRateAnalysisResultsData, } from '../log_rate_analysis_results'; -import type { GroupTableItem } from '../../log_rate_analysis_results_table/types'; -import { useLogRateAnalysisResultsTableRowContext } from '../../log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider'; const DEFAULT_SEARCH_QUERY: estypes.QueryDslQueryContainer = { match_all: {} }; const DEFAULT_SEARCH_BAR_QUERY: estypes.QueryDslQueryContainer = { @@ -66,8 +65,6 @@ export function getDocumentCountStatsSplitLabel( export interface LogRateAnalysisContentProps { /** The data view to analyze. */ dataView: DataView; - /** Timestamp for the start of the range for initial analysis */ - initialAnalysisStart?: number | WindowParameters; timeRange?: { min: Moment; max: Moment }; /** Elasticsearch query to pass to analysis endpoint */ esSearchQuery?: estypes.QueryDslQueryContainer; @@ -87,7 +84,6 @@ export interface LogRateAnalysisContentProps { export const LogRateAnalysisContent: FC = ({ dataView, - initialAnalysisStart: incomingInitialAnalysisStart, timeRange, esSearchQuery = DEFAULT_SEARCH_QUERY, stickyHistogram, @@ -98,9 +94,6 @@ export const LogRateAnalysisContent: FC = ({ embeddingOrigin, }) => { const [windowParameters, setWindowParameters] = useState(); - const [initialAnalysisStart, setInitialAnalysisStart] = useState< - number | WindowParameters | undefined - >(incomingInitialAnalysisStart); const [isBrushCleared, setIsBrushCleared] = useState(true); const [logRateAnalysisType, setLogRateAnalysisType] = useState( LOG_RATE_ANALYSIS_TYPE.SPIKE @@ -140,13 +133,16 @@ export const LogRateAnalysisContent: FC = ({ ); const { + autoRunAnalysis, currentSelectedSignificantItem, currentSelectedGroup, + setAutoRunAnalysis, + setInitialAnalysisStart, setPinnedSignificantItem, setPinnedGroup, setSelectedSignificantItem, setSelectedGroup, - } = useLogRateAnalysisResultsTableRowContext(); + } = useLogRateAnalysisStateContext(); const { documentStats, earliest, latest } = useData( dataView, @@ -206,7 +202,11 @@ export const LogRateAnalysisContent: FC = ({ } : undefined; - const triggerAnalysis = useCallback(() => { + const triggerAnalysisForManualSelection = useCallback(() => { + setAutoRunAnalysis(true); + }, [setAutoRunAnalysis]); + + const triggerAnalysisForChangePoint = useCallback(() => { if (documentCountStats) { const { interval, timeRangeEarliest, timeRangeLatest, changePoint } = documentCountStats; @@ -222,14 +222,37 @@ export const LogRateAnalysisContent: FC = ({ const snapTimestamps = getSnappedTimestamps(timeRangeEarliest, timeRangeLatest, interval); const wpSnap = getSnappedWindowParameters(wp, snapTimestamps); + triggerAnalysisForManualSelection(); setInitialAnalysisStart(wpSnap); } } - }, [documentCountStats]); + }, [documentCountStats, setInitialAnalysisStart, triggerAnalysisForManualSelection]); + + const showDocumentCountContent = documentCountStats !== undefined; + + const showLogRateAnalysisResults = + autoRunAnalysis && + earliest !== undefined && + latest !== undefined && + windowParameters !== undefined; + + const showNoAutoRunEmptyPrompt = + !autoRunAnalysis && + earliest !== undefined && + latest !== undefined && + windowParameters !== undefined; + + const showSpikeDetectedEmptyPrompt = + windowParameters === undefined && documentCountStats?.changePoint; + + const showDefaultEmptyPrompt = + windowParameters === undefined && documentCountStats?.changePoint === undefined; + + const changePointType = documentCountStats?.changePoint?.type; return ( - {documentCountStats !== undefined && ( + {showDocumentCountContent && ( = ({ isBrushCleared={isBrushCleared} totalCount={totalCount} sampleProbability={sampleProbability} - initialAnalysisStart={initialAnalysisStart} barColorOverride={barColorOverride} barHighlightColorOverride={barHighlightColorOverride} barStyleAccessor={barStyleAccessor} /> )} - {earliest !== undefined && latest !== undefined && windowParameters !== undefined && ( + {showLogRateAnalysisResults && ( = ({ embeddingOrigin={embeddingOrigin} /> )} - {windowParameters === undefined && documentCountStats?.changePoint && ( + {showNoAutoRunEmptyPrompt && ( + +

+ +

+ + + {' '} + clearSelection()} + color="text" + > + + + + } + data-test-subj="aiopsChangePointDetectedPrompt" + /> + )} + {showSpikeDetectedEmptyPrompt && ( = ({ css={{ minWidth: '100%' }} title={

- {documentCountStats?.changePoint.type === LOG_RATE_ANALYSIS_TYPE.SPIKE && ( + {changePointType === LOG_RATE_ANALYSIS_TYPE.SPIKE && ( )} - {documentCountStats?.changePoint.type === LOG_RATE_ANALYSIS_TYPE.DIP && ( + {changePointType === LOG_RATE_ANALYSIS_TYPE.DIP && ( )} - {documentCountStats?.changePoint.type !== LOG_RATE_ANALYSIS_TYPE.SPIKE && - documentCountStats?.changePoint.type !== LOG_RATE_ANALYSIS_TYPE.DIP && ( + {changePointType !== LOG_RATE_ANALYSIS_TYPE.SPIKE && + changePointType !== LOG_RATE_ANALYSIS_TYPE.DIP && ( = ({

= ({ data-test-subj="aiopsChangePointDetectedPrompt" /> )} - {windowParameters === undefined && documentCountStats?.changePoint === undefined && ( + {showDefaultEmptyPrompt && ( = ({

} diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx index 8655256b4da8..524780d16c20 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx @@ -18,13 +18,13 @@ import { UrlStateProvider } from '@kbn/ml-url-state'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { DatePickerContextProvider } from '@kbn/ml-date-picker'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; +import { LogRateAnalysisStateProvider } from '@kbn/aiops-components'; import { timeSeriesDataViewWarning } from '../../../application/utils/time_series_dataview_check'; import { AiopsAppContext, type AiopsAppDependencies } from '../../../hooks/use_aiops_app_context'; import { DataSourceContext } from '../../../hooks/use_data_source'; import { AIOPS_STORAGE_KEYS } from '../../../types/storage'; -import { LogRateAnalysisResultsTableRowStateProvider } from '../../log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider'; import { LogRateAnalysisContent } from './log_rate_analysis_content'; import type { LogRateAnalysisResultsData } from '../log_rate_analysis_results'; @@ -92,12 +92,11 @@ export const LogRateAnalysisContentWrapper: FC - + - + diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx index 90227fd7915a..254d58c93675 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx @@ -18,6 +18,7 @@ import { useUrlState, usePageUrlState } from '@kbn/ml-url-state'; import type { SearchQueryLanguage } from '@kbn/ml-query-utils'; import type { WindowParameters } from '@kbn/aiops-log-rate-analysis'; import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { useLogRateAnalysisStateContext } from '@kbn/aiops-components'; import { useDataSource } from '../../hooks/use_data_source'; import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; @@ -31,7 +32,6 @@ import { } from '../../application/url_state/log_rate_analysis'; import { SearchPanel } from '../search_panel'; -import { useLogRateAnalysisResultsTableRowContext } from '../log_rate_analysis_results_table/log_rate_analysis_results_table_row_provider'; import { PageHeader } from '../page_header'; import { LogRateAnalysisContent } from './log_rate_analysis_content/log_rate_analysis_content'; @@ -43,8 +43,8 @@ export const LogRateAnalysisPage: FC = ({ stickyHistogram }) => { const { data: dataService } = useAiopsAppContext(); const { dataView, savedSearch } = useDataSource(); - const { currentSelectedSignificantItem, currentSelectedGroup } = - useLogRateAnalysisResultsTableRowContext(); + const { currentSelectedSignificantItem, currentSelectedGroup, setInitialAnalysisStart } = + useLogRateAnalysisStateContext(); const [stateFromUrl, setUrlState] = usePageUrlState( 'logRateAnalysis', @@ -142,6 +142,14 @@ export const LogRateAnalysisPage: FC = ({ stickyHistogram }) => { }); }, [dataService, searchQueryLanguage, searchString]); + useEffect( + () => { + setInitialAnalysisStart(appStateToWindowParameters(stateFromUrl.wp)); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); + const onWindowParametersHandler = (wp?: WindowParameters, replace = false) => { if (!isEqual(windowParametersToAppState(wp), stateFromUrl.wp)) { setUrlState( @@ -169,7 +177,6 @@ export const LogRateAnalysisPage: FC = ({ stickyHistogram }) => { /> = ({ // to be able to track it across rerenders. const analysisStartTime = useRef(window.performance.now()); - const { clearAllRowState } = useLogRateAnalysisResultsTableRowContext(); + const { clearAllRowState } = useLogRateAnalysisStateContext(); const [currentAnalysisType, setCurrentAnalysisType] = useState(); const [currentAnalysisWindowParameters, setCurrentAnalysisWindowParameters] = useState< diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_group_table_items.ts b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_group_table_items.ts index 6767b8244494..c33713e111f0 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_group_table_items.ts +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_group_table_items.ts @@ -8,8 +8,7 @@ import { sortBy } from 'lodash'; import type { SignificantItemGroup } from '@kbn/ml-agg-utils'; - -import type { GroupTableItem, GroupTableItemGroup } from './types'; +import type { GroupTableItem, GroupTableItemGroup } from '@kbn/aiops-components'; export function getGroupTableItems( significantItemsGroups: SignificantItemGroup[] diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_table_item_as_kql.ts b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_table_item_as_kql.ts index 97717d43cb12..6ac66468b658 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_table_item_as_kql.ts +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/get_table_item_as_kql.ts @@ -7,8 +7,7 @@ import { escapeKuery, escapeQuotes } from '@kbn/es-query'; import { isSignificantItem, type SignificantItem } from '@kbn/ml-agg-utils'; - -import type { GroupTableItem } from './types'; +import type { GroupTableItem } from '@kbn/aiops-components'; export const getTableItemAsKQL = (tableItem: GroupTableItem | SignificantItem) => { if (isSignificantItem(tableItem)) { diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx index e19663e064d6..ff683855f6d3 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx @@ -32,13 +32,13 @@ import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker'; import { getCategoryQuery } from '@kbn/aiops-log-pattern-analysis/get_category_query'; +import { useLogRateAnalysisStateContext } from '@kbn/aiops-components'; import { useEuiTheme } from '../../hooks/use_eui_theme'; import { MiniHistogram } from '../mini_histogram'; import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; import { getFailedTransactionsCorrelationImpactLabel } from './get_failed_transactions_correlation_impact_label'; -import { useLogRateAnalysisResultsTableRowContext } from './log_rate_analysis_results_table_row_provider'; import { FieldStatsPopover } from '../field_stats_popover'; import { useCopyToClipboardAction } from './use_copy_to_clipboard_action'; import { useViewInDiscoverAction } from './use_view_in_discover_action'; @@ -93,7 +93,7 @@ export const LogRateAnalysisResultsTable: FC = selectedSignificantItem, setPinnedSignificantItem, setSelectedSignificantItem, - } = useLogRateAnalysisResultsTableRowContext(); + } = useLogRateAnalysisStateContext(); const [pageIndex, setPageIndex] = useState(0); const [pageSize, setPageSize] = useState(10); diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx index cf3afc272066..aefe170fc4b5 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx @@ -32,13 +32,12 @@ import type { SignificantItem } from '@kbn/ml-agg-utils'; import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker'; import type { DataView } from '@kbn/data-views-plugin/public'; import { stringHash } from '@kbn/ml-string-hash'; +import { useLogRateAnalysisStateContext, type GroupTableItem } from '@kbn/aiops-components'; import { MiniHistogram } from '../mini_histogram'; import { getFailedTransactionsCorrelationImpactLabel } from './get_failed_transactions_correlation_impact_label'; import { LogRateAnalysisResultsTable } from './log_rate_analysis_results_table'; -import { useLogRateAnalysisResultsTableRowContext } from './log_rate_analysis_results_table_row_provider'; -import type { GroupTableItem } from './types'; import { useCopyToClipboardAction } from './use_copy_to_clipboard_action'; import { useViewInDiscoverAction } from './use_view_in_discover_action'; import { useViewInLogPatternAnalysisAction } from './use_view_in_log_pattern_analysis_action'; @@ -97,7 +96,7 @@ export const LogRateAnalysisResultsGroupsTable: FC { diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.test.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.test.tsx index 8e3b68f4ec27..c110e8b2d56c 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.test.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.test.tsx @@ -14,10 +14,10 @@ import type { SignificantItem } from '@kbn/ml-agg-utils'; import { finalSignificantItemGroups } from '@kbn/aiops-test-utils/artificial_logs/final_significant_item_groups'; import { significantTerms } from '@kbn/aiops-test-utils/artificial_logs/significant_terms'; +import type { GroupTableItem } from '@kbn/aiops-components'; import { getGroupTableItems } from './get_group_table_items'; import { useCopyToClipboardAction } from './use_copy_to_clipboard_action'; -import type { GroupTableItem } from './types'; interface Action { render: (tableItem: SignificantItem | GroupTableItem) => ReactElement; diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.tsx index b7dc328f1a46..403adfdbf070 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_copy_to_clipboard_action.tsx @@ -11,10 +11,10 @@ import { EuiCopy, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { isSignificantItem, type SignificantItem } from '@kbn/ml-agg-utils'; +import type { GroupTableItem, TableItemAction } from '@kbn/aiops-components'; import { TableActionButton } from './table_action_button'; import { getTableItemAsKQL } from './get_table_item_as_kql'; -import type { GroupTableItem, TableItemAction } from './types'; const copyToClipboardButtonLabel = i18n.translate( 'xpack.aiops.logRateAnalysis.resultsTable.linksMenu.copyToClipboardButtonLabel', diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_discover_action.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_discover_action.tsx index 7f467ded4c24..7f657617517a 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_discover_action.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_discover_action.tsx @@ -9,13 +9,13 @@ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import type { SignificantItem } from '@kbn/ml-agg-utils'; - import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils'; +import type { GroupTableItem, TableItemAction } from '@kbn/aiops-components'; + import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; import { TableActionButton } from './table_action_button'; import { getTableItemAsKQL } from './get_table_item_as_kql'; -import type { GroupTableItem, TableItemAction } from './types'; const viewInDiscoverMessage = i18n.translate( 'xpack.aiops.logRateAnalysis.resultsTable.linksMenu.viewInDiscover', diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_log_pattern_analysis_action.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_log_pattern_analysis_action.tsx index 3f75654d4280..6c29ee4607d6 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_log_pattern_analysis_action.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/use_view_in_log_pattern_analysis_action.tsx @@ -11,13 +11,13 @@ import type { SerializableRecord } from '@kbn/utility-types'; import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import { isSignificantItem, type SignificantItem, SIGNIFICANT_ITEM_TYPE } from '@kbn/ml-agg-utils'; +import type { GroupTableItem, TableItemAction } from '@kbn/aiops-components'; import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils'; import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; import { TableActionButton } from './table_action_button'; import { getTableItemAsKQL } from './get_table_item_as_kql'; -import type { GroupTableItem, TableItemAction } from './types'; const isLogPattern = (tableItem: SignificantItem | GroupTableItem) => isSignificantItem(tableItem) && tableItem.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN; diff --git a/x-pack/plugins/aiops/public/get_document_stats.ts b/x-pack/plugins/aiops/public/get_document_stats.ts index f693dc8f6751..0846565cc189 100644 --- a/x-pack/plugins/aiops/public/get_document_stats.ts +++ b/x-pack/plugins/aiops/public/get_document_stats.ts @@ -18,9 +18,9 @@ import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { SignificantItem } from '@kbn/ml-agg-utils'; import type { Query } from '@kbn/es-query'; import type { RandomSamplerWrapper } from '@kbn/ml-random-sampler-utils'; +import type { GroupTableItem } from '@kbn/aiops-components'; import { buildExtendedBaseFilterCriteria } from './application/utils/build_extended_base_filter_criteria'; -import type { GroupTableItem } from './components/log_rate_analysis_results_table/types'; export interface DocumentCountStats { interval?: number; diff --git a/x-pack/plugins/aiops/public/hooks/use_data.ts b/x-pack/plugins/aiops/public/hooks/use_data.ts index 64cb69f2dcdd..9986a4d65dd7 100644 --- a/x-pack/plugins/aiops/public/hooks/use_data.ts +++ b/x-pack/plugins/aiops/public/hooks/use_data.ts @@ -18,9 +18,9 @@ import type { Dictionary } from '@kbn/ml-url-state'; import { mlTimefilterRefresh$, useTimefilter } from '@kbn/ml-date-picker'; import { useTimeBuckets } from '@kbn/ml-time-buckets'; import { AIOPS_PLUGIN_ID } from '@kbn/aiops-common/constants'; +import type { GroupTableItem } from '@kbn/aiops-components'; import type { DocumentStatsSearchStrategyParams } from '../get_document_stats'; -import type { GroupTableItem } from '../components/log_rate_analysis_results_table/types'; import { useAiopsAppContext } from './use_aiops_app_context'; diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis.ts index 3d3a629599ae..7308d561109b 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis.ts @@ -80,6 +80,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await ml.testExecution.logTestStep('clicks the document count chart to start analysis'); await aiops.logRateAnalysisPage.clickDocumentCountChart(testData.chartClickCoordinates); + + if (!testData.autoRun) { + await aiops.logRateAnalysisPage.assertNoAutoRunButtonExists(); + await aiops.logRateAnalysisPage.clickNoAutoRunButton(); + } + await aiops.logRateAnalysisPage.assertAnalysisSectionExists(); if (testData.brushDeviationTargetTimestamp) { diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/artificial_log_data_view_test_data.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/artificial_log_data_view_test_data.ts index a04d6aea22ba..ff6bfd4f9f19 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/artificial_log_data_view_test_data.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/artificial_log_data_view_test_data.ts @@ -34,12 +34,14 @@ interface GetArtificialLogDataViewTestDataOptions { analysisType: LogRateAnalysisType; textField: boolean; zeroDocsFallback: boolean; + autoRun: boolean; } export const getArtificialLogDataViewTestData = ({ analysisType, textField, zeroDocsFallback, + autoRun, }: GetArtificialLogDataViewTestDataOptions): TestData => { function getAnalysisGroupsTable() { if (zeroDocsFallback) { @@ -133,6 +135,7 @@ export const getArtificialLogDataViewTestData = ({ return { suiteTitle: getSuiteTitle(), analysisType, + autoRun, dataGenerator: getDataGenerator(), isSavedSearch: false, sourceIndexOrSavedSearch: getDataGenerator(), diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data.ts index a1e860e55a49..07b116e544e2 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data.ts @@ -12,6 +12,7 @@ import type { TestData } from '../../types'; export const farequoteDataViewTestData: TestData = { suiteTitle: 'farequote with spike', analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, + autoRun: false, dataGenerator: 'farequote_with_spike', isSavedSearch: false, sourceIndexOrSavedSearch: 'ft_farequote', diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data_with_query.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data_with_query.ts index 29d49bbdf8ac..14e754550f60 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data_with_query.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/farequote_data_view_test_data_with_query.ts @@ -12,6 +12,7 @@ import type { TestData } from '../../types'; export const farequoteDataViewTestDataWithQuery: TestData = { suiteTitle: 'farequote with spike', analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, + autoRun: false, dataGenerator: 'farequote_with_spike', isSavedSearch: false, sourceIndexOrSavedSearch: 'ft_farequote', diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/kibana_logs_data_view_test_data.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/kibana_logs_data_view_test_data.ts index 1e4f019ed901..4a5f9dddb6f1 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/kibana_logs_data_view_test_data.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis/test_data/kibana_logs_data_view_test_data.ts @@ -13,6 +13,7 @@ import type { TestData } from '../../types'; export const kibanaLogsDataViewTestData: TestData = { suiteTitle: 'kibana sample data logs', analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, + autoRun: true, dataGenerator: 'kibana_sample_data_logs', isSavedSearch: false, sourceIndexOrSavedSearch: 'kibana_sample_data_logstsdb', diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis_test_data.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis_test_data.ts index 2b5ca3e37861..8fd0be5fa2b5 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis_test_data.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis_test_data.ts @@ -22,40 +22,48 @@ export const logRateAnalysisTestData: TestData[] = [ analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, textField: false, zeroDocsFallback: false, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, textField: true, zeroDocsFallback: false, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.DIP, textField: false, zeroDocsFallback: false, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.DIP, textField: true, zeroDocsFallback: false, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, textField: true, zeroDocsFallback: true, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE, textField: false, zeroDocsFallback: true, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.DIP, textField: true, zeroDocsFallback: true, + autoRun: false, }), getArtificialLogDataViewTestData({ analysisType: LOG_RATE_ANALYSIS_TYPE.DIP, textField: false, zeroDocsFallback: true, + autoRun: false, }), ]; diff --git a/x-pack/test/functional/apps/aiops/types.ts b/x-pack/test/functional/apps/aiops/types.ts index cb4005dcacde..0f8f4a4d07d2 100644 --- a/x-pack/test/functional/apps/aiops/types.ts +++ b/x-pack/test/functional/apps/aiops/types.ts @@ -54,6 +54,7 @@ interface TestDataExpectedWithoutSampleProbability { export interface TestData { suiteTitle: string; analysisType: LogRateAnalysisType; + autoRun: boolean; dataGenerator: LogRateAnalysisDataGenerator; isSavedSearch?: boolean; sourceIndexOrSavedSearch: string; diff --git a/x-pack/test/functional/services/aiops/log_rate_analysis_page.ts b/x-pack/test/functional/services/aiops/log_rate_analysis_page.ts index dde260c40825..1a33ede2e700 100644 --- a/x-pack/test/functional/services/aiops/log_rate_analysis_page.ts +++ b/x-pack/test/functional/services/aiops/log_rate_analysis_page.ts @@ -133,6 +133,16 @@ export function LogRateAnalysisPageProvider({ getService, getPageObject }: FtrPr await this.assertHistogramBrushesExist(); }, + async clickNoAutoRunButton() { + await testSubjects.clickWhenNotDisabledWithoutRetry( + 'aiopsLogRateAnalysisNoAutoRunContentRunAnalysisButton' + ); + + await retry.tryForTime(30 * 1000, async () => { + await testSubjects.missingOrFail('aiopsLogRateAnalysisNoAutoRunContentRunAnalysisButton'); + }); + }, + async clickRerunAnalysisButton(shouldRerun: boolean) { await testSubjects.clickWhenNotDisabledWithoutRetry( `aiopsRerunAnalysisButton${shouldRerun ? ' shouldRerun' : ''}` @@ -250,6 +260,10 @@ export function LogRateAnalysisPageProvider({ getService, getPageObject }: FtrPr ); }, + async assertNoAutoRunButtonExists() { + await testSubjects.existOrFail('aiopsLogRateAnalysisNoAutoRunContentRunAnalysisButton'); + }, + async assertProgressTitle(expectedProgressTitle: string) { await retry.tryForTime(30 * 1000, async () => { await testSubjects.existOrFail('aiopProgressTitle');