Skip to content

Commit

Permalink
[ML] Removing global isServerless flag (#166651)
Browse files Browse the repository at this point in the history
Removed `isServerless` flag which lived in our global context and had to
be passed about to the various components which create their own version
of the context using `getMlGlobalServices`
This PR adds a new context which contains flags for all of the features
which can be toggled when in serverless mode.
Flags added:
```
 showNodeInfo
 showMLNavMenu
 showLicenseInfo
 isADEnabled
 isDFAEnabled
 isNLPEnabled
```
The enabled features flags are now read from the config file client
side, rather than using capabilities.

Additional changes:
- Changes the wording of the awaiting ML node callout in serverless.
- In the search project, the default ML page is the trained models list
and not Overview
- Reenables the Memory Usage page for all projects

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jgowdyelastic and kibanamachine authored Sep 27, 2023
1 parent e522f0a commit c18513e
Show file tree
Hide file tree
Showing 76 changed files with 398 additions and 378 deletions.
3 changes: 3 additions & 0 deletions test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.license_management.ui.enabled (boolean)',
'xpack.maps.preserveDrawingBuffer (boolean)',
'xpack.maps.showMapsInspectorAdapter (boolean)',
'xpack.ml.ad.enabled (boolean)',
'xpack.ml.dfa.enabled (boolean)',
'xpack.ml.nlp.enabled (boolean)',
'xpack.osquery.actionEnabled (boolean)',
'xpack.remote_clusters.ui.enabled (boolean)',
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ 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 @@ -96,13 +92,12 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
disabled,
callback,
apiPath,
hideFrozenDataTierChoice = false,
} = props;

const {
http,
notifications: { toasts },
isServerless,
showFrozenDataTierChoice,
} = useDatePickerContext();

// wrapper around setFullTimeRange to allow for the calling of the optional callBack prop
Expand All @@ -114,9 +109,7 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
toasts,
http,
query,
isServerless || hideFrozenDataTierChoice
? false
: frozenDataPreference === FROZEN_TIER_PREFERENCE.EXCLUDE,
showFrozenDataTierChoice ? frozenDataPreference === FROZEN_TIER_PREFERENCE.EXCLUDE : false,
apiPath
);
if (typeof callback === 'function' && fullTimeRange !== undefined) {
Expand All @@ -138,8 +131,7 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
toasts,
http,
query,
isServerless,
hideFrozenDataTierChoice,
showFrozenDataTierChoice,
frozenDataPreference,
apiPath,
callback,
Expand Down Expand Up @@ -230,7 +222,7 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
/>
</EuiButton>
</EuiToolTip>
{isServerless || hideFrozenDataTierChoice ? null : (
{showFrozenDataTierChoice ? (
<EuiFlexItem grow={false}>
<EuiPopover
id={'mlFullTimeRangeSelectorOption'}
Expand All @@ -256,7 +248,7 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
{popoverContent}
</EuiPopover>
</EuiFlexItem>
)}
) : null}
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export interface DatePickerDependencies {
*/
i18n: I18nStart;
/**
* Optional flag to indicate whether kibana is running in serverless
* Optional flag to disable the frozen data tier choice.
*/
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ export interface ChangePointDetectionAppStateProps {
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

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

const warning = timeSeriesDataViewWarning(dataView, 'change_point_detection');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export interface LogCategorizationAppStateProps {
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

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

Expand All @@ -56,7 +56,7 @@ export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
showFrozenDataTierChoice,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export interface LogRateAnalysisAppStateProps {
/** Option to make main histogram sticky */
stickyHistogram?: boolean;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

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

Expand All @@ -62,7 +62,7 @@ export const LogRateAnalysisAppState: FC<LogRateAnalysisAppStateProps> = ({
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
showFrozenDataTierChoice,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface LogRateAnalysisContentWrapperProps {
*/
onAnalysisCompleted?: (d: LogRateAnalysisResultsData) => void;
/** Optional flag to indicate whether kibana is running in serverless */
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

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

Expand All @@ -85,6 +85,7 @@ export const LogRateAnalysisContentWrapper: FC<LogRateAnalysisContentWrapperProp
const datePickerDeps = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
showFrozenDataTierChoice,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ export const DataVisualizerStateContextProvider: FC<DataVisualizerStateContextPr

interface Props {
getAdditionalLinks?: GetAdditionalLinks;
isServerless?: boolean;
showFrozenDataTierChoice?: boolean;
}

export const IndexDataVisualizer: FC<Props> = ({ getAdditionalLinks, isServerless = false }) => {
export const IndexDataVisualizer: FC<Props> = ({
getAdditionalLinks,
showFrozenDataTierChoice = true,
}) => {
const coreStart = getCoreStart();
const {
data,
Expand Down Expand Up @@ -302,7 +305,7 @@ export const IndexDataVisualizer: FC<Props> = ({ getAdditionalLinks, isServerles
const datePickerDeps: DatePickerDependencies = {
...pick(services, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
isServerless,
showFrozenDataTierChoice,
};

return (
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/ml/common/constants/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,23 @@ export const ML_APP_NAME = i18n.translate('xpack.ml.navMenu.mlAppNameText', {
export const ML_APP_ROUTE = '/app/ml';
export const ML_INTERNAL_BASE_PATH = '/internal/ml';
export const ML_EXTERNAL_BASE_PATH = '/api/ml';

export type MlFeatures = Record<'ad' | 'dfa' | 'nlp', boolean>;

export interface ConfigSchema {
ad?: { enabled: boolean };
dfa?: { enabled: boolean };
nlp?: { enabled: boolean };
}

export function initEnabledFeatures(enabledFeatures: MlFeatures, config: ConfigSchema) {
if (config.ad?.enabled !== undefined) {
enabledFeatures.ad = config.ad.enabled;
}
if (config.dfa?.enabled !== undefined) {
enabledFeatures.dfa = config.dfa.enabled;
}
if (config.nlp?.enabled !== undefined) {
enabledFeatures.nlp = config.nlp.enabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ import { ChangePointDetection } from '@kbn/aiops-plugin/public';

import { useDataSource } from '../contexts/ml/data_source_context';
import { useFieldStatsTrigger, FieldStatsFlyoutProvider } from '../components/field_stats_flyout';
import { useMlKibana, useIsServerless } from '../contexts/kibana';
import { useMlKibana } from '../contexts/kibana';
import { HelpMenu } from '../components/help_menu';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';

import { MlPageHeader } from '../components/page_header';
import { useEnabledFeatures } from '../contexts/ml/serverless_context';

export const ChangePointDetectionPage: FC = () => {
const { services } = useMlKibana();
const isServerless = useIsServerless();
const { showNodeInfo } = useEnabledFeatures();

const { selectedDataView: dataView, selectedSavedSearch: savedSearch } = useDataSource();

Expand All @@ -46,7 +47,7 @@ export const ChangePointDetectionPage: FC = () => {
<ChangePointDetection
dataView={dataView}
savedSearch={savedSearch}
isServerless={isServerless}
showFrozenDataTierChoice={showNodeInfo}
appDependencies={{
...pick(services, [
'application',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { LogCategorization } from '@kbn/aiops-plugin/public';
import { useDataSource } from '../contexts/ml/data_source_context';
import { useMlKibana, useIsServerless } from '../contexts/kibana';
import { useMlKibana } from '../contexts/kibana';
import { useEnabledFeatures } from '../contexts/ml';
import { HelpMenu } from '../components/help_menu';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';
import { MlPageHeader } from '../components/page_header';

export const LogCategorizationPage: FC = () => {
const { services } = useMlKibana();
const isServerless = useIsServerless();
const { showNodeInfo } = useEnabledFeatures();

const { selectedDataView: dataView, selectedSavedSearch: savedSearch } = useDataSource();

Expand All @@ -41,7 +42,7 @@ export const LogCategorizationPage: FC = () => {
<LogCategorization
dataView={dataView}
savedSearch={savedSearch}
isServerless={isServerless}
showFrozenDataTierChoice={showNodeInfo}
appDependencies={pick(services, [
'application',
'data',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { LogRateAnalysis } from '@kbn/aiops-plugin/public';
import { useDataSource } from '../contexts/ml/data_source_context';
import { useMlKibana, useIsServerless } from '../contexts/kibana';
import { useMlKibana } from '../contexts/kibana';
import { HelpMenu } from '../components/help_menu';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';
import { MlPageHeader } from '../components/page_header';
import { useEnabledFeatures } from '../contexts/ml';

export const LogRateAnalysisPage: FC = () => {
const { services } = useMlKibana();
const isServerless = useIsServerless();
const { showNodeInfo } = useEnabledFeatures();

const { selectedDataView: dataView, selectedSavedSearch: savedSearch } = useDataSource();

Expand All @@ -44,7 +45,7 @@ export const LogRateAnalysisPage: FC = () => {
stickyHistogram={false}
dataView={dataView}
savedSearch={savedSearch}
isServerless={isServerless}
showFrozenDataTierChoice={showNodeInfo}
appDependencies={pick(services, [
'application',
'data',
Expand Down
Loading

0 comments on commit c18513e

Please sign in to comment.