diff --git a/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx index 931c60059c0b0..3e54920160c53 100644 --- a/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx @@ -11,12 +11,10 @@ import { encode } from 'rison-node'; import { TimeRange } from '../../../../common/http_api/shared/time_range'; import { useLinkProps, LinkDescriptor } from '../../../hooks/use_link_props'; -type DatemathRange = TimeRange | { startTime: string; endTime: string }; - export const AnalyzeInMlButton: React.FunctionComponent<{ jobId: string; partition?: string; - timeRange: DatemathRange; + timeRange: TimeRange; }> = ({ jobId, partition, timeRange }) => { const linkProps = useLinkProps( typeof partition === 'string' @@ -44,7 +42,7 @@ export const AnalyzeInMlButton: React.FunctionComponent<{ export const getOverallAnomalyExplorerLinkDescriptor = ( jobId: string, - timeRange: DatemathRange + timeRange: TimeRange ): LinkDescriptor => { const { from, to } = convertTimeRangeToParams(timeRange); @@ -67,7 +65,7 @@ export const getOverallAnomalyExplorerLinkDescriptor = ( export const getEntitySpecificSingleMetricViewerLink = ( jobId: string, - timeRange: DatemathRange, + timeRange: TimeRange, entities: Record ): LinkDescriptor => { const { from, to } = convertTimeRangeToParams(timeRange); @@ -96,15 +94,9 @@ export const getEntitySpecificSingleMetricViewerLink = ( }; }; -const convertTimeRangeToParams = (timeRange: DatemathRange): { from: string; to: string } => { +const convertTimeRangeToParams = (timeRange: TimeRange): { from: string; to: string } => { return { - from: - typeof timeRange.startTime === 'number' - ? new Date(timeRange.startTime).toISOString() - : timeRange.startTime, - to: - typeof timeRange.endTime === 'number' - ? new Date(timeRange.endTime).toISOString() - : timeRange.endTime, + from: new Date(timeRange.startTime).toISOString(), + to: new Date(timeRange.endTime).toISOString(), }; }; diff --git a/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_flyout/module_list.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_flyout/module_list.tsx index c38db73a01980..d7414950b35ad 100644 --- a/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_flyout/module_list.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_flyout/module_list.tsx @@ -17,7 +17,6 @@ import { } from '../../../../containers/logs/log_analysis/modules/log_entry_rate'; import { LogAnalysisModuleListCard } from './module_list_card'; import type { ModuleId } from './setup_flyout_state'; -import { useLogAnalysisResultsUrlState } from '../../../../pages/logs/log_entry_rate/use_log_entry_rate_results_url_state'; export const LogAnalysisModuleList: React.FC<{ onViewModuleSetup: (module: ModuleId) => void; @@ -32,8 +31,6 @@ export const LogAnalysisModuleList: React.FC<{ jobIds: logEntryCategoriesJobIds, } = useLogEntryCategoriesModuleContext(); - const { timeRange } = useLogAnalysisResultsUrlState(); - const viewLogEntryRateSetupFlyout = useCallback(() => { onViewModuleSetup('logs_ui_analysis'); }, [onViewModuleSetup]); @@ -47,7 +44,6 @@ export const LogAnalysisModuleList: React.FC<{ void; }> = ({ jobId, - timeRange, hasSetupCapabilities, moduleDescription, moduleName, @@ -36,7 +34,12 @@ export const LogAnalysisModuleListCard: React.FC<{ ); - const viewInMlLinkProps = useLinkProps(getOverallAnomalyExplorerLinkDescriptor(jobId, timeRange)); + const viewInMlLinkProps = useLinkProps( + getOverallAnomalyExplorerLinkDescriptor(jobId, { + endTime: Date.now(), + startTime: Date.now() - 86400000 * 14, + }) + ); const moduleSetupButton = moduleStatus.type === 'required' ? (