Skip to content

Commit

Permalink
[ML] Log pattern analysis non time series check (elastic#160021)
Browse files Browse the repository at this point in the history
Adds the check for non-time series data views to the Log Pattern
Analysis.
As all three AIOPs features now have the same check, I moved it to a
common component.

Part of elastic#159355
  • Loading branch information
jgowdyelastic committed Jun 20, 2023
1 parent 2422c01 commit 851b641
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.
*/

import React from 'react';

import { EuiCallOut } from '@elastic/eui';

import type { DataView } from '@kbn/data-views-plugin/common';
import { i18n } from '@kbn/i18n';

export function timeSeriesDataViewWarning(
dataView: DataView,
feature: 'change_point_detection' | 'log_categorization' | 'explain_log_rate_spikes'
) {
if (dataView.isTimeBased()) {
return null;
}

let description = '';
if (feature === 'change_point_detection') {
description = i18n.translate('xpack.aiops.changePointTimeSeriesWarning.description', {
defaultMessage: 'Change point detection only runs over time-based indices.',
});
} else if (feature === 'log_categorization') {
description = i18n.translate('xpack.aiops.logCategorizationTimeSeriesWarning.description', {
defaultMessage: 'Log pattern analysis only runs over time-based indices.',
});
} else if (feature === 'explain_log_rate_spikes') {
description = i18n.translate('xpack.aiops.logRateSpikesTimeSeriesWarning.description', {
defaultMessage: 'Log rate spikes only runs over time-based indices.',
});
}

return (
<EuiCallOut
title={i18n.translate('xpack.aiops.dataViewNotBasedOnTimeSeriesWarning.title', {
defaultMessage: 'The data view "{dataViewTitle}" is not based on a time series.',
values: { dataViewTitle: dataView.getName() },
})}
color="danger"
iconType="warning"
>
<p>{description}</p>
</EuiCallOut>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { FC } from 'react';
import { pick } from 'lodash';

import { EuiCallOut, EuiSpacer } from '@elastic/eui';
import { EuiSpacer } from '@elastic/eui';

import { DataView } from '@kbn/data-views-plugin/common';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
Expand All @@ -19,7 +19,6 @@ import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';

import { i18n } from '@kbn/i18n';
import { DataSourceContext } from '../../hooks/use_data_source';
import { AiopsAppContext, AiopsAppDependencies } from '../../hooks/use_aiops_app_context';
import { AIOPS_STORAGE_KEYS } from '../../types/storage';
Expand All @@ -28,6 +27,7 @@ import { PageHeader } from '../page_header';

import { ChangePointDetectionPage } from './change_point_detection_page';
import { ChangePointDetectionContextProvider } from './change_point_detection_context';
import { timeSeriesDataViewWarning } from '../../application/utils/time_series_dataview_check';

const localStorage = new Storage(window.localStorage);

Expand All @@ -49,23 +49,10 @@ export const ChangePointDetectionAppState: FC<ChangePointDetectionAppStateProps>
uiSettingsKeys: UI_SETTINGS,
};

if (!dataView.isTimeBased()) {
return (
<EuiCallOut
title={i18n.translate('xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle', {
defaultMessage: 'The data view "{dataViewTitle}" is not based on a time series.',
values: { dataViewTitle: dataView.getName() },
})}
color="danger"
iconType="warning"
>
<p>
{i18n.translate('xpack.aiops.index.changePointTimeSeriesNotificationDescription', {
defaultMessage: 'Change point detection only runs over time-based indices.',
})}
</p>
</EuiCallOut>
);
const warning = timeSeriesDataViewWarning(dataView, 'change_point_detection');

if (warning !== null) {
return <>{warning}</>;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import React, { FC } from 'react';
import { pick } from 'lodash';

import { EuiCallOut } from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { StorageContextProvider } from '@kbn/ml-local-storage';
Expand All @@ -28,6 +25,7 @@ import { AIOPS_STORAGE_KEYS } from '../../types/storage';
import { SpikeAnalysisTableRowStateProvider } from '../spike_analysis_table/spike_analysis_table_row_provider';

import { ExplainLogRateSpikesPage } from './explain_log_rate_spikes_page';
import { timeSeriesDataViewWarning } from '../../application/utils/time_series_dataview_check';

const localStorage = new Storage(window.localStorage);

Expand All @@ -50,23 +48,10 @@ export const ExplainLogRateSpikesAppState: FC<ExplainLogRateSpikesAppStateProps>
}) => {
if (!dataView) return null;

if (!dataView.isTimeBased()) {
return (
<EuiCallOut
title={i18n.translate('xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle', {
defaultMessage: 'The data view "{dataViewTitle}" is not based on a time series.',
values: { dataViewTitle: dataView.getName() },
})}
color="danger"
iconType="warning"
>
<p>
{i18n.translate('xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationDescription', {
defaultMessage: 'Log rate spike analysis only runs over time-based indices.',
})}
</p>
</EuiCallOut>
);
const warning = timeSeriesDataViewWarning(dataView, 'explain_log_rate_spikes');

if (warning !== null) {
return <>{warning}</>;
}

const datePickerDeps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { pick } from 'lodash';
import type { Moment } from 'moment';

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { EuiCallOut } from '@elastic/eui';

import type { WindowParameters } from '@kbn/aiops-utils';
import { i18n } from '@kbn/i18n';
import type { DataView } from '@kbn/data-views-plugin/public';
import { StorageContextProvider } from '@kbn/ml-local-storage';
import { UrlStateProvider } from '@kbn/ml-url-state';
Expand All @@ -22,6 +20,7 @@ import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';

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';
Expand Down Expand Up @@ -68,23 +67,10 @@ export const ExplainLogRateSpikesContentWrapper: FC<ExplainLogRateSpikesContentW
}) => {
if (!dataView) return null;

if (!dataView.isTimeBased()) {
return (
<EuiCallOut
title={i18n.translate('xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle', {
defaultMessage: 'The data view "{dataViewTitle}" is not based on a time series.',
values: { dataViewTitle: dataView.getName() },
})}
color="danger"
iconType="warning"
>
<p>
{i18n.translate('xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationDescription', {
defaultMessage: 'Log rate spike analysis only runs over time-based indices.',
})}
</p>
</EuiCallOut>
);
const warning = timeSeriesDataViewWarning(dataView, 'explain_log_rate_spikes');

if (warning !== null) {
return <>{warning}</>;
}

const datePickerDeps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { AIOPS_STORAGE_KEYS } from '../../types/storage';
import { AiopsAppContext } from '../../hooks/use_aiops_app_context';

import { LogCategorizationPage } from './log_categorization_page';
import { timeSeriesDataViewWarning } from '../../application/utils/time_series_dataview_check';

const localStorage = new Storage(window.localStorage);

Expand All @@ -36,6 +37,14 @@ export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
savedSearch,
appDependencies,
}) => {
if (!dataView) return null;

const warning = timeSeriesDataViewWarning(dataView, 'log_categorization');

if (warning !== null) {
return <>{warning}</>;
}

const datePickerDeps = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings']),
toMountPoint,
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -7091,7 +7091,6 @@
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupItemsInfo": "Affichage de {valuesBadges} éléments sur {count}.",
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupUniqueItemsInfo": "{count, plural, one {# élément} many {Éléments #} other {Éléments #}} unique(s) à ce groupe.",
"xpack.aiops.index.dataLoader.internalServerErrorMessage": "Erreur lors du chargement des données dans l'index {index}. {message}. La requête a peut-être expiré. Essayez d'utiliser un échantillon d'une taille inférieure ou de réduire la plage temporelle.",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle": "La vue de données \"{dataViewTitle}\" n'est pas basée sur une série temporelle.",
"xpack.aiops.index.dataViewWithoutMetricNotificationTitle": "La vue de données \"{dataViewTitle}\" ne contient aucun champ d'indicateurs.",
"xpack.aiops.index.errorLoadingDataMessage": "Erreur lors du chargement des données dans l'index {index}. {message}.",
"xpack.aiops.logCategorization.counts": "{count} modèles trouvés",
Expand Down Expand Up @@ -7193,8 +7192,6 @@
"xpack.aiops.fieldContextPopover.descriptionTooltipContent": "Afficher les principales valeurs de champ",
"xpack.aiops.fieldContextPopover.notTopTenValueMessage": "Le terme sélectionné n'est pas dans le top 10",
"xpack.aiops.fieldContextPopover.topFieldValuesAriaLabel": "Afficher les principales valeurs de champ",
"xpack.aiops.index.changePointTimeSeriesNotificationDescription": "La détection des points de modification ne s'exécute que sur des index temporels.",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationDescription": "L'analyse des pics de taux de log ne fonctionne que sur des index temporels.",
"xpack.aiops.index.dataViewWithoutMetricNotificationDescription": "La détection des points de modification peut être exécutée uniquement sur des vues de données possédant un champ d'indicateur.",
"xpack.aiops.logCategorization.categoryFieldSelect": "Champ de catégorie",
"xpack.aiops.logCategorization.chartPointsSplitLabel": "Modèle sélectionné",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -7092,7 +7092,6 @@
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupItemsInfo": "{count}項目中{valuesBadges}項目を表示しています。",
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupUniqueItemsInfo": "このグループに固有の{count, plural, other {#アイテム}}。",
"xpack.aiops.index.dataLoader.internalServerErrorMessage": "インデックス{index}のデータの読み込み中にエラーが発生。{message}。リクエストがタイムアウトした可能性があります。小さなサンプルサイズを使うか、時間範囲を狭めてみてください。",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle": "データビュー\"{dataViewTitle}\"は時系列に基づいていません。",
"xpack.aiops.index.dataViewWithoutMetricNotificationTitle": "データビュー\"{dataViewTitle}\"にはメトリックフィールドが含まれていません。",
"xpack.aiops.index.errorLoadingDataMessage": "インデックス{index}のデータの読み込み中にエラーが発生。{message}。",
"xpack.aiops.logCategorization.counts": "{count}個のパターンが見つかりました",
Expand Down Expand Up @@ -7194,8 +7193,6 @@
"xpack.aiops.fieldContextPopover.descriptionTooltipContent": "上位のフィールド値を表示",
"xpack.aiops.fieldContextPopover.notTopTenValueMessage": "選択した用語は上位10件にありません",
"xpack.aiops.fieldContextPopover.topFieldValuesAriaLabel": "上位のフィールド値を表示",
"xpack.aiops.index.changePointTimeSeriesNotificationDescription": "変化点の検出は時間ベースのインデックスでのみ実行されます",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationDescription": "ログレートスパイクは、時間ベースのインデックスに対してのみ実行されます。",
"xpack.aiops.index.dataViewWithoutMetricNotificationDescription": "変化点の検出は、メトリックフィールドがあるデータビューでのみ実行できます。",
"xpack.aiops.logCategorization.categoryFieldSelect": "カテゴリーフィールド",
"xpack.aiops.logCategorization.chartPointsSplitLabel": "選択したパターン",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7091,7 +7091,6 @@
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupItemsInfo": "正在显示 {valuesBadges} 个(共 {count} 个)项目。",
"xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.groupUniqueItemsInfo": "{count, plural, other {# 项}}对此组唯一。",
"xpack.aiops.index.dataLoader.internalServerErrorMessage": "加载索引 {index} 中的数据时出错。{message}。请求可能已超时。请尝试使用较小的样例大小或缩小时间范围。",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationTitle": "数据视图“{dataViewTitle}”并非基于时间序列。",
"xpack.aiops.index.dataViewWithoutMetricNotificationTitle": "数据视图“{dataViewTitle}”不包含任何指标字段。",
"xpack.aiops.index.errorLoadingDataMessage": "加载索引 {index} 中的数据时出错。{message}。",
"xpack.aiops.logCategorization.counts": "找到 {count} 个模式",
Expand Down Expand Up @@ -7193,8 +7192,6 @@
"xpack.aiops.fieldContextPopover.descriptionTooltipContent": "显示排名靠前字段值",
"xpack.aiops.fieldContextPopover.notTopTenValueMessage": "选定的词未排名前 10",
"xpack.aiops.fieldContextPopover.topFieldValuesAriaLabel": "显示排名靠前字段值",
"xpack.aiops.index.changePointTimeSeriesNotificationDescription": "仅针对基于时间的索引运行更改点检测。",
"xpack.aiops.index.dataViewNotBasedOnTimeSeriesNotificationDescription": "日志速率峰值分析仅在基于时间的索引上运行。",
"xpack.aiops.index.dataViewWithoutMetricNotificationDescription": "只能在包含指标字段的数据视图上运行更改点检测。",
"xpack.aiops.logCategorization.categoryFieldSelect": "类别字段",
"xpack.aiops.logCategorization.chartPointsSplitLabel": "选定的模式",
Expand Down

0 comments on commit 851b641

Please sign in to comment.