From 8e74867e3036530a5b68b46128051c0d5d3c9cce Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 23 Aug 2024 14:28:04 +0100 Subject: [PATCH 1/3] [ML] AIOps: Using no minimum time range by default for pattern analysis --- .../minimum_time_range.ts | 2 ++ .../use_minimum_time_range.ts | 4 ++-- .../pattern_analysis/pattern_analysis_initializer.tsx | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts index 623f76919063f..ab8d5ca889ba3 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts @@ -7,6 +7,8 @@ import { i18n } from '@kbn/i18n'; import type { unitOfTime } from 'moment'; +export const DEFAULT_MINIMUM_TIME_RANGE_OPTION: MinimumTimeRangeOption = 'No minimum'; + export type MinimumTimeRangeOption = 'No minimum' | '1 week' | '1 month' | '3 months' | '6 months'; type MinimumTimeRange = Record< diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/use_minimum_time_range.ts b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/use_minimum_time_range.ts index 3bb3c0ab1ad5f..50328a2ef345c 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/use_minimum_time_range.ts +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/use_minimum_time_range.ts @@ -15,7 +15,7 @@ import { useStorage } from '@kbn/ml-local-storage'; import type { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { useAiopsAppContext } from '../../../hooks/use_aiops_app_context'; import type { MinimumTimeRangeOption } from './minimum_time_range'; -import { MINIMUM_TIME_RANGE } from './minimum_time_range'; +import { DEFAULT_MINIMUM_TIME_RANGE_OPTION, MINIMUM_TIME_RANGE } from './minimum_time_range'; import type { AiOpsKey, AiOpsStorageMapped } from '../../../types/storage'; import { AIOPS_PATTERN_ANALYSIS_MINIMUM_TIME_RANGE_PREFERENCE } from '../../../types/storage'; @@ -85,7 +85,7 @@ export function useMinimumTimeRange() { const [minimumTimeRangeOption, setMinimumTimeRangeOption] = useStorage< AiOpsKey, AiOpsStorageMapped - >(AIOPS_PATTERN_ANALYSIS_MINIMUM_TIME_RANGE_PREFERENCE, '1 week'); + >(AIOPS_PATTERN_ANALYSIS_MINIMUM_TIME_RANGE_PREFERENCE, DEFAULT_MINIMUM_TIME_RANGE_OPTION); const cancelRequest = useCallback(() => { abortController.current.abort(); diff --git a/x-pack/plugins/aiops/public/embeddables/pattern_analysis/pattern_analysis_initializer.tsx b/x-pack/plugins/aiops/public/embeddables/pattern_analysis/pattern_analysis_initializer.tsx index 4ed1dadf3dc1e..f44fff343fb50 100644 --- a/x-pack/plugins/aiops/public/embeddables/pattern_analysis/pattern_analysis_initializer.tsx +++ b/x-pack/plugins/aiops/public/embeddables/pattern_analysis/pattern_analysis_initializer.tsx @@ -38,7 +38,10 @@ import { DEFAULT_PROBABILITY, RANDOM_SAMPLER_OPTION, } from '../../components/log_categorization/sampling_menu/random_sampler'; -import type { MinimumTimeRangeOption } from '../../components/log_categorization/log_categorization_for_embeddable/minimum_time_range'; +import { + DEFAULT_MINIMUM_TIME_RANGE_OPTION, + type MinimumTimeRangeOption, +} from '../../components/log_categorization/log_categorization_for_embeddable/minimum_time_range'; import { getMessageField } from '../../components/log_categorization/utils'; import { FieldSelector } from '../../components/log_categorization/log_categorization_for_embeddable/field_selector'; import { SamplingPanel } from '../../components/log_categorization/sampling_menu/sampling_panel'; @@ -67,7 +70,7 @@ export const PatternAnalysisEmbeddableInitializer: FC( pick( initialInput ?? { - minimumTimeRangeOption: '1 week', + minimumTimeRangeOption: DEFAULT_MINIMUM_TIME_RANGE_OPTION, randomSamplerMode: RANDOM_SAMPLER_OPTION.ON_AUTOMATIC, randomSamplerProbability: DEFAULT_PROBABILITY, }, From 6dde6aeea297dba9908faae55026020d3e4e7f43 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 29 Aug 2024 09:39:37 +0100 Subject: [PATCH 2/3] updating text --- .../log_categorization_for_embeddable/embeddable_menu.tsx | 7 ++++++- .../minimum_time_range.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx index 42124e39c07c0..e5823e9a43dcd 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx @@ -158,7 +158,12 @@ export const PatternAnalysisSettings: FC = ({ values={{ minimumTimeRangeOption, categoryCount }} /> - ) : null} + ) : ( + + )} } > diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts index ab8d5ca889ba3..3380d5e31e833 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/minimum_time_range.ts @@ -19,7 +19,7 @@ type MinimumTimeRange = Record< export const MINIMUM_TIME_RANGE: MinimumTimeRange = { 'No minimum': { label: i18n.translate('xpack.aiops.logCategorization.minimumTimeRange.noMin', { - defaultMessage: 'No minimum', + defaultMessage: 'Use range specified in time selector', }), factor: 0, unit: 'w', From 5082a3f25485cf68f49ac9c051edb568d67e9a07 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 29 Aug 2024 09:58:48 +0100 Subject: [PATCH 3/3] adding a . --- .../log_categorization_for_embeddable/embeddable_menu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx index e5823e9a43dcd..55b63c18081b8 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/embeddable_menu.tsx @@ -161,7 +161,7 @@ export const PatternAnalysisSettings: FC = ({ ) : ( )}