Skip to content

Commit

Permalink
[ML] AIOps: Using no minimum time range by default for pattern analys…
Browse files Browse the repository at this point in the history
…is (#191192)

Changing the default selection from `1 week` to `No minimum`.
For indices with very large doc counts, it is safer not to query a
week's worth of data by default, but rather use the time range selected
in the time picker.
  • Loading branch information
jgowdyelastic authored Aug 29, 2024
1 parent 38f4aa0 commit 525d9f6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ export const PatternAnalysisSettings: FC<PatternAnalysisSettingsProps> = ({
values={{ minimumTimeRangeOption, categoryCount }}
/>
</>
) : null}
) : (
<FormattedMessage
id="xpack.aiops.logCategorization.embeddableMenu.totalPatternsMessage2"
defaultMessage="No additional time will be added to the range you specified with the time selector."
/>
)}
</>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -17,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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -85,7 +85,7 @@ export function useMinimumTimeRange() {
const [minimumTimeRangeOption, setMinimumTimeRangeOption] = useStorage<
AiOpsKey,
AiOpsStorageMapped<typeof AIOPS_PATTERN_ANALYSIS_MINIMUM_TIME_RANGE_PREFERENCE>
>(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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -67,7 +70,7 @@ export const PatternAnalysisEmbeddableInitializer: FC<PatternAnalysisInitializer
const [formInput, setFormInput] = useState<PatternAnalysisEmbeddableRuntimeState>(
pick(
initialInput ?? {
minimumTimeRangeOption: '1 week',
minimumTimeRangeOption: DEFAULT_MINIMUM_TIME_RANGE_OPTION,
randomSamplerMode: RANDOM_SAMPLER_OPTION.ON_AUTOMATIC,
randomSamplerProbability: DEFAULT_PROBABILITY,
},
Expand Down

0 comments on commit 525d9f6

Please sign in to comment.