Skip to content

Commit

Permalink
[ML] Serverless compatibility fixes (elastic#163724)
Browse files Browse the repository at this point in the history
**ML Management page**
- Fixes general page loading issues.
- Ensures only enabled features are shown as tabs
- Ensures only jobs for enabled features can be exported and imported.
- Ensures only enabled features are listed in the saved object sync
output.
- On trained models tab:
  - Only lists DFA models if NLP is disabled.
  - Only lists non-DFA models if DFA is disabled.

**Anomaly Detection**
- Hides node information in anomaly detection jobs list.
- Hides the Exclude frozen data option in the Use full time range
selector in job wizards.

**Data frame analytics**
 - Hides all node and license level information.

**Trained models**
 - Only lists DFA models if NLP is disabled.
 - Only lists non-DFA models if DFA is disabled.
 - Hides all node and license level information.
 - Hides DFA nodes 

**Notifications and memory usage**
- Ensures only enabled features are mentioned. Including selectable
types in the search bar filters.

**Integrations with other plugins**
- Changes registration for integrations into other plugins so they only
happen if the relevant feature is enabled.
   - Client side: UI actions, cases, embeddables, alerts, maps.
   - Server side: Sample data sets, cases

**AIOPS**
- Hides the Exclude frozen data option in the Use full time range
selector on all pages

**Notes for non ML team reviewers**

**response-ops**
I've divided the
[persistable_state.ts](elastic#163724 (comment))
test into basic and trial version.
The ML cases attachments should only be registered if anomaly detection
is available in a trial or platinum license. This was a bug which I
noticed when making serverless changes.

 **Observability**
I've made a few minor changes to the nav menu, fixing names of ML
features and adding the missing Change point detection AIOPs page.

**Security solution**
I've made a few minor changes to the nav menu, fixing names of ML
features and adding some missing ML features.
I think the icons being used will need to be revisited before release as
we have [official ML
icons](https://elastic.github.io/eui/#/display/icons#apps) but not for
every page. So we should probably either have new icons created or all
agree on which standard non-ML icons should be used for the ones which
are missing.

**Search**
The NLP feature is currently disabled in main, I believe this was an
attempt to stop ML anomaly detection alert rules from being registered.
I've reenabled NLP and changed the way we're registering the alerts.
They will now only be registered if the anomaly detection feature is
enabled.


Fixes elastic#163372
  • Loading branch information
jgowdyelastic authored Sep 13, 2023
1 parent 1abe8c0 commit 09faf89
Show file tree
Hide file tree
Showing 102 changed files with 1,579 additions and 929 deletions.
6 changes: 6 additions & 0 deletions packages/default-nav/ml/default_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export const defaultNavigation: MlNodeDefinition = {
}),
link: 'ml:indexDataVisualizer',
},
{
title: i18n.translate('defaultNavigation.ml.dataComparison', {
defaultMessage: 'Data comparison',
}),
link: 'ml:dataComparison',
},
],
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const allNavLinks: AppDeepLinkId[] = [
'ml:fileUpload',
'ml:filterListsSettings',
'ml:indexDataVisualizer',
'ml:dataComparison',
'ml:logPatternAnalysis',
'ml:logRateAnalysis',
'ml:memoryUsage',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export interface FullTimeRangeSelectorProps {
* @param value - The time field range response.
*/
apiPath?: SetFullTimeRangeApiPath;
/**
* Optional flag to disable the frozen data tier choice.
*/
hideFrozenDataTierChoice?: boolean;
}

/**
Expand All @@ -92,10 +96,12 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
disabled,
callback,
apiPath,
hideFrozenDataTierChoice = false,
} = props;
const {
http,
notifications: { toasts },
isServerless,
} = useDatePickerContext();

// wrapper around setFullTimeRange to allow for the calling of the optional callBack prop
Expand All @@ -107,7 +113,9 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
toasts,
http,
query,
frozenDataPreference === FROZEN_TIER_PREFERENCE.EXCLUDE,
isServerless || hideFrozenDataTierChoice
? false
: frozenDataPreference === FROZEN_TIER_PREFERENCE.EXCLUDE,
apiPath
);
if (typeof callback === 'function' && fullTimeRange !== undefined) {
Expand All @@ -123,7 +131,18 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
)
);
}
}, [callback, dataView, frozenDataPreference, http, query, timefilter, toasts, apiPath]);
}, [
timefilter,
dataView,
toasts,
http,
query,
isServerless,
hideFrozenDataTierChoice,
frozenDataPreference,
apiPath,
callback,
]);

const [isPopoverOpen, setPopover] = useState(false);

Expand Down Expand Up @@ -210,31 +229,33 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
/>
</EuiButton>
</EuiToolTip>
<EuiFlexItem grow={false}>
<EuiPopover
id={'mlFullTimeRangeSelectorOption'}
button={
<EuiButtonIcon
display="base"
size="m"
iconType="boxesVertical"
aria-label={i18n.translate(
'xpack.ml.datePicker.fullTimeRangeSelector.moreOptionsButtonAriaLabel',
{
defaultMessage: 'More options',
}
)}
onClick={onButtonClick}
/>
}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="downRight"
>
{popoverContent}
</EuiPopover>
</EuiFlexItem>
{isServerless || hideFrozenDataTierChoice ? null : (
<EuiFlexItem grow={false}>
<EuiPopover
id={'mlFullTimeRangeSelectorOption'}
button={
<EuiButtonIcon
display="base"
size="m"
iconType="boxesVertical"
aria-label={i18n.translate(
'xpack.ml.datePicker.fullTimeRangeSelector.moreOptionsButtonAriaLabel',
{
defaultMessage: 'More options',
}
)}
onClick={onButtonClick}
/>
}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="downRight"
>
{popoverContent}
</EuiPopover>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export interface DatePickerDependencies {
* Internationalisation service
*/
i18n: I18nStart;
/**
* Optional flag to indicate whether kibana is running in serverless
*/
isServerless?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { StorageContextProvider } from '@kbn/ml-local-storage';
import { UrlStateProvider } from '@kbn/ml-url-state';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DatePickerContextProvider, mlTimefilterRefresh$ } from '@kbn/ml-date-picker';
import {
DatePickerContextProvider,
type DatePickerDependencies,
mlTimefilterRefresh$,
} from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';

import { type Observable } from 'rxjs';
Expand Down Expand Up @@ -46,16 +50,20 @@ export interface ChangePointDetectionAppStateProps {
savedSearch: SavedSearch | null;
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
}

export const ChangePointDetectionAppState: FC<ChangePointDetectionAppStateProps> = ({
dataView,
savedSearch,
appDependencies,
isServerless = false,
}) => {
const datePickerDeps = {
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
};

const warning = timeSeriesDataViewWarning(dataView, 'change_point_detection');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import { StorageContextProvider } from '@kbn/ml-local-storage';
import { UrlStateProvider } from '@kbn/ml-url-state';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';

import { DataSourceContext } from '../../hooks/use_data_source';
Expand All @@ -35,12 +35,15 @@ export interface LogCategorizationAppStateProps {
savedSearch: SavedSearch | null;
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
}

export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
dataView,
savedSearch,
appDependencies,
isServerless = false,
}) => {
if (!dataView) return null;

Expand All @@ -50,9 +53,10 @@ export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
return <>{warning}</>;
}

const datePickerDeps = {
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import { StorageContextProvider } from '@kbn/ml-local-storage';
import { UrlStateProvider } from '@kbn/ml-url-state';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';

import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context';
Expand All @@ -40,13 +40,16 @@ export interface LogRateAnalysisAppStateProps {
appDependencies: AiopsAppDependencies;
/** Option to make main histogram sticky */
stickyHistogram?: boolean;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
}

export const LogRateAnalysisAppState: FC<LogRateAnalysisAppStateProps> = ({
dataView,
savedSearch,
appDependencies,
stickyHistogram,
isServerless = false,
}) => {
if (!dataView) return null;

Expand All @@ -56,9 +59,10 @@ export const LogRateAnalysisAppState: FC<LogRateAnalysisAppStateProps> = ({
return <>{warning}</>;
}

const datePickerDeps = {
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export interface LogRateAnalysisContentWrapperProps {
* @param d Log rate analysis results data
*/
onAnalysisCompleted?: (d: LogRateAnalysisResultsData) => void;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
}

export const LogRateAnalysisContentWrapper: FC<LogRateAnalysisContentWrapperProps> = ({
Expand All @@ -70,6 +72,7 @@ export const LogRateAnalysisContentWrapper: FC<LogRateAnalysisContentWrapperProp
barColorOverride,
barHighlightColorOverride,
onAnalysisCompleted,
isServerless = false,
}) => {
if (!dataView) return null;

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/aiops/public/hooks/use_aiops_app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export interface AiopsAppDependencies {
presentationUtil?: PresentationUtilPluginStart;
embeddable?: EmbeddableStart;
cases?: CasesUiStart;
isServerless?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-pl
import { StorageContextProvider } from '@kbn/ml-local-storage';
import { DataView } from '@kbn/data-views-plugin/public';
import { getNestedProperty } from '@kbn/ml-nested-property';
import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import {
Provider as UrlStateContextProvider,
Expand Down Expand Up @@ -263,9 +263,12 @@ export const DataVisualizerStateContextProvider: FC<DataVisualizerStateContextPr
);
};

export const IndexDataVisualizer: FC<{
interface Props {
getAdditionalLinks?: GetAdditionalLinks;
}> = ({ getAdditionalLinks }) => {
isServerless?: boolean;
}

export const IndexDataVisualizer: FC<Props> = ({ getAdditionalLinks, isServerless = false }) => {
const coreStart = getCoreStart();
const {
data,
Expand Down Expand Up @@ -296,9 +299,10 @@ export const IndexDataVisualizer: FC<{
unifiedSearch,
...coreStart,
};
const datePickerDeps = {
const datePickerDeps: DatePickerDependencies = {
...pick(services, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
};

return (
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/common/constants/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const PLUGIN_ICON_SOLUTION = 'logoKibana';
export const ML_APP_NAME = i18n.translate('xpack.ml.navMenu.mlAppNameText', {
defaultMessage: 'Machine Learning',
});
export const ML_APP_ROUTE = '/app/ml';
export const ML_INTERNAL_BASE_PATH = '/internal/ml';
export const ML_EXTERNAL_BASE_PATH = '/api/ml';
Loading

0 comments on commit 09faf89

Please sign in to comment.