Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Integrates into serverless kibana #159433

Merged
merged 47 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9a8ccdc
[ML] Integrating into serverless kibana
jgowdyelastic Jun 10, 2023
c11e161
removing temp debugging code
jgowdyelastic Jun 10, 2023
ae9b242
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 10, 2023
186450e
adding type keyword
jgowdyelastic Jun 10, 2023
becbc5b
Merge remote-tracking branch 'origin/main' into ml-serverless-compati…
jgowdyelastic Jun 12, 2023
3c40d28
Merge remote-tracking branch 'origin/main' into ml-serverless-compati…
jgowdyelastic Jun 13, 2023
a1661d4
updating navigation menus for es and observability
jgowdyelastic Jun 13, 2023
5ad8f61
updating capabilities switcher
jgowdyelastic Jun 13, 2023
8b70ee0
correcting icon
jgowdyelastic Jun 13, 2023
05bf8bb
Merge remote-tracking branch 'origin/main' into ml-serverless-compati…
jgowdyelastic Jun 14, 2023
68bc89d
Merge remote-tracking branch 'origin/main' into ml-serverless-compati…
jgowdyelastic Jun 14, 2023
9509dba
registering deeplinks based on features
jgowdyelastic Jun 14, 2023
ccca708
fixing types
jgowdyelastic Jun 14, 2023
1bd3ffb
disabling notifications
jgowdyelastic Jun 14, 2023
8dfae15
fixing types
jgowdyelastic Jun 14, 2023
770910a
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 15, 2023
9871236
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 19, 2023
abf97f1
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 19, 2023
2b7467f
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 19, 2023
f1e7ff8
fixing mocked nav
jgowdyelastic Jun 19, 2023
98385e3
fixing capabilities tests
jgowdyelastic Jun 19, 2023
7c2c77c
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 20, 2023
fbcf0f3
Merge remote-tracking branch 'origin/main' into ml-serverless-compati…
jgowdyelastic Jun 23, 2023
3e18119
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 26, 2023
fb48d6d
filtering notifications based on type
jgowdyelastic Jun 26, 2023
7976b22
adding missing import
jgowdyelastic Jun 26, 2023
3d8f891
removing comment
jgowdyelastic Jun 26, 2023
f1934cd
updating comment
jgowdyelastic Jun 26, 2023
4c4feb7
type keyword
jgowdyelastic Jun 26, 2023
fcdac6d
page access checks
jgowdyelastic Jun 26, 2023
f3b9a34
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 26, 2023
880836f
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 27, 2023
8f4e744
removing nav menu shared function
jgowdyelastic Jun 27, 2023
99195a6
removing old isServerless function
jgowdyelastic Jun 27, 2023
4206474
removing old isServerless hook
jgowdyelastic Jun 27, 2023
20d8b32
fixing background color
jgowdyelastic Jun 27, 2023
4b97c8e
removing background color overrides
jgowdyelastic Jun 27, 2023
35eeb66
fixing mock
jgowdyelastic Jun 27, 2023
a1b822d
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 28, 2023
826b9d2
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 29, 2023
c29461a
fixing links when not in serverless
jgowdyelastic Jun 29, 2023
3a53e15
adding ml back into oblt menu
jgowdyelastic Jun 29, 2023
3a7eae1
removing ml section from oblt
jgowdyelastic Jun 29, 2023
82a51a7
adjusting overview page
jgowdyelastic Jun 29, 2023
61a2370
fixing canViewMlNodes value for viewer users
jgowdyelastic Jun 29, 2023
ec63b24
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 30, 2023
3cab0e9
Merge branch 'main' into ml-serverless-compatibility
jgowdyelastic Jun 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/default-nav/ml/default_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export type MlNodeDefinition = NodeDefinitionWithChildren<DeepLinkId, Navigation
export const defaultNavigation: MlNodeDefinition = {
id: 'rootNav:ml',
title: i18n.translate('defaultNavigation.ml.machineLearning', {
defaultMessage: 'Machine learning',
defaultMessage: 'Machine Learning',
}),
icon: 'indexMapping',
icon: 'machineLearningApp',
children: [
{
title: '',
Expand Down Expand Up @@ -65,7 +65,7 @@ export const defaultNavigation: MlNodeDefinition = {
{
id: 'data_frame_analytics',
title: i18n.translate('defaultNavigation.ml.dataFrameAnalytics', {
defaultMessage: 'Data frame analytics',
defaultMessage: 'Data Frame Analytics',
}),
children: [
{
Expand All @@ -83,7 +83,7 @@ export const defaultNavigation: MlNodeDefinition = {
{
id: 'model_management',
title: i18n.translate('defaultNavigation.ml.modelManagement', {
defaultMessage: 'Model management',
defaultMessage: 'Model Management',
}),
children: [
{
Expand All @@ -97,7 +97,7 @@ export const defaultNavigation: MlNodeDefinition = {
{
id: 'data_visualizer',
title: i18n.translate('defaultNavigation.ml.dataVisualizer', {
defaultMessage: 'Data visualizer',
defaultMessage: 'Data Visualizer',
}),
children: [
{
Expand All @@ -121,14 +121,14 @@ export const defaultNavigation: MlNodeDefinition = {
}),
children: [
{
title: i18n.translate('defaultNavigation.ml.explainLogRateSpikes', {
defaultMessage: 'Explain log rate spikes',
}),
link: 'ml:explainLogRateSpikes',
},
{
link: 'ml:logPatternAnalysis',
},
{
link: 'ml:changePointDetections',
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { MockRouter, mockDependencies } from '../../__mocks__';

import { RequestHandlerContext } from '@kbn/core/server';
import { MlTrainedModels } from '@kbn/ml-plugin/server';

import { SharedServices } from '@kbn/ml-plugin/server/shared_services';
import type { MlPluginSetup, MlTrainedModels } from '@kbn/ml-plugin/server';

import { ErrorCode } from '../../../common/types/error_codes';

Expand Down Expand Up @@ -168,7 +167,7 @@ describe('Enterprise Search Managed Indices', () => {
});

describe('GET /internal/enterprise_search/indices/{indexName}/ml_inference/pipeline_processors', () => {
let mockMl: SharedServices;
let mockMl: MlPluginSetup;
let mockTrainedModelsProvider: MlTrainedModels;

beforeEach(() => {
Expand All @@ -195,7 +194,7 @@ describe('Enterprise Search Managed Indices', () => {

mockMl = {
trainedModelsProvider: () => Promise.resolve(mockTrainedModelsProvider),
} as unknown as jest.Mocked<SharedServices>;
} as unknown as jest.Mocked<MlPluginSetup>;

registerIndexRoutes({
...mockDependencies,
Expand Down Expand Up @@ -1069,7 +1068,7 @@ describe('Enterprise Search Managed Indices', () => {

describe('GET /internal/enterprise_search/pipelines/ml_inference', () => {
let mockTrainedModelsProvider: MlTrainedModels;
let mockMl: SharedServices;
let mockMl: MlPluginSetup;

beforeEach(() => {
const context = {
Expand All @@ -1095,7 +1094,7 @@ describe('Enterprise Search Managed Indices', () => {

mockMl = {
trainedModelsProvider: () => Promise.resolve(mockTrainedModelsProvider),
} as unknown as jest.Mocked<SharedServices>;
} as unknown as jest.Mocked<MlPluginSetup>;

registerIndexRoutes({
...mockDependencies,
Expand Down Expand Up @@ -1134,7 +1133,7 @@ describe('Enterprise Search Managed Indices', () => {
});

describe('POST /internal/enterprise_search/ml/models/{modelName}', () => {
let mockMl: SharedServices;
let mockMl: MlPluginSetup;
let mockTrainedModelsProvider: MlTrainedModels;

beforeEach(() => {
Expand All @@ -1156,7 +1155,7 @@ describe('Enterprise Search Managed Indices', () => {

mockMl = {
trainedModelsProvider: () => Promise.resolve(mockTrainedModelsProvider),
} as unknown as jest.Mocked<SharedServices>;
} as unknown as jest.Mocked<MlPluginSetup>;

registerIndexRoutes({
...mockDependencies,
Expand Down Expand Up @@ -1198,7 +1197,7 @@ describe('Enterprise Search Managed Indices', () => {
});

describe('POST /internal/enterprise_search/ml/models/{modelName}/deploy', () => {
let mockMl: SharedServices;
let mockMl: MlPluginSetup;
let mockTrainedModelsProvider: MlTrainedModels;

beforeEach(() => {
Expand All @@ -1220,7 +1219,7 @@ describe('Enterprise Search Managed Indices', () => {

mockMl = {
trainedModelsProvider: () => Promise.resolve(mockTrainedModelsProvider),
} as unknown as jest.Mocked<SharedServices>;
} as unknown as jest.Mocked<MlPluginSetup>;

registerIndexRoutes({
...mockDependencies,
Expand Down Expand Up @@ -1262,7 +1261,7 @@ describe('Enterprise Search Managed Indices', () => {
});

describe('GET /internal/enterprise_search/ml/models/{modelName}', () => {
let mockMl: SharedServices;
let mockMl: MlPluginSetup;
let mockTrainedModelsProvider: MlTrainedModels;

beforeEach(() => {
Expand All @@ -1283,7 +1282,7 @@ describe('Enterprise Search Managed Indices', () => {

mockMl = {
trainedModelsProvider: () => Promise.resolve(mockTrainedModelsProvider),
} as unknown as jest.Mocked<SharedServices>;
} as unknown as jest.Mocked<MlPluginSetup>;

registerIndexRoutes({
...mockDependencies,
Expand Down
75 changes: 69 additions & 6 deletions x-pack/plugins/ml/common/types/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const apmUserMlCapabilities = {
canGetJobs: false,
};

export const featureMlCapabilities = {
isADEnabled: true,
isDFAEnabled: true,
isNLPEnabled: true,
};

export const userMlCapabilities = {
// Anomaly Detection
canGetJobs: false,
Expand Down Expand Up @@ -80,19 +86,21 @@ export const adminMlCapabilities = {
canStartStopTrainedModels: false,
};

export type FeatureMlCapabilities = typeof featureMlCapabilities;
export type UserMlCapabilities = typeof userMlCapabilities;
export type AdminMlCapabilities = typeof adminMlCapabilities;
export type MlCapabilities = UserMlCapabilities & AdminMlCapabilities;
export type MlCapabilities = FeatureMlCapabilities & UserMlCapabilities & AdminMlCapabilities;
export type MlCapabilitiesKey = keyof MlCapabilities;

export const basicLicenseMlCapabilities = [
export const basicLicenseMlCapabilities: MlCapabilitiesKey[] = [
'canFindFileStructure',
'canGetFieldInfo',
'canGetMlInfo',
] as Array<keyof MlCapabilities>;
];

export function getDefaultCapabilities(): MlCapabilities {
return {
...featureMlCapabilities,
...userMlCapabilities,
...adminMlCapabilities,
};
Expand All @@ -101,8 +109,13 @@ export function getDefaultCapabilities(): MlCapabilities {
export function getPluginPrivileges() {
const apmUserMlCapabilitiesKeys = Object.keys(apmUserMlCapabilities);
const userMlCapabilitiesKeys = Object.keys(userMlCapabilities);
const featureMlCapabilitiesKeys = Object.keys(featureMlCapabilities);
const adminMlCapabilitiesKeys = Object.keys(adminMlCapabilities);
const allMlCapabilitiesKeys = [...adminMlCapabilitiesKeys, ...userMlCapabilitiesKeys];
const allMlCapabilitiesKeys = [
...featureMlCapabilitiesKeys,
...adminMlCapabilitiesKeys,
...userMlCapabilitiesKeys,
];

const savedObjects = [
'index-pattern',
Expand Down Expand Up @@ -143,10 +156,13 @@ export function getPluginPrivileges() {
},
user: {
...privilege,
api: ['fileUpload:analyzeFile', ...userMlCapabilitiesKeys.map((k) => `ml:${k}`)],
api: [
'fileUpload:analyzeFile',
...[...featureMlCapabilitiesKeys, ...userMlCapabilitiesKeys].map((k) => `ml:${k}`),
],
catalogue: [PLUGIN_ID],
management: { insightsAndAlerting: [] },
ui: userMlCapabilitiesKeys,
ui: [...featureMlCapabilitiesKeys, ...userMlCapabilitiesKeys],
savedObject: {
all: [],
read: savedObjects,
Expand Down Expand Up @@ -182,3 +198,50 @@ export interface MlCapabilitiesResponse {
}

export type ResolveMlCapabilities = (request: KibanaRequest) => Promise<MlCapabilities | null>;

interface FeatureCapabilities {
ad: MlCapabilitiesKey[];
dfa: MlCapabilitiesKey[];
nlp: MlCapabilitiesKey[];
darnautov marked this conversation as resolved.
Show resolved Hide resolved
}

export const featureCapabilities: FeatureCapabilities = {
ad: [
'canGetJobs',
'canGetDatafeeds',
'canGetCalendars',
'canGetAnnotations',
'canCreateAnnotation',
'canDeleteAnnotation',
'canCreateJob',
'canDeleteJob',
'canOpenJob',
'canCloseJob',
'canResetJob',
'canUpdateJob',
'canForecastJob',
'canCreateDatafeed',
'canDeleteDatafeed',
'canStartStopDatafeed',
'canUpdateDatafeed',
'canPreviewDatafeed',
'canGetFilters',
'canCreateCalendar',
'canDeleteCalendar',
'canCreateFilter',
'canDeleteFilter',
],
dfa: [
'canGetDataFrameAnalytics',
'canCreateDataFrameAnalytics',
'canDeleteDataFrameAnalytics',
'canStartStopDataFrameAnalytics',
],
nlp: [
'canGetTrainedModels',
'canTestTrainedModels',
'canCreateTrainedModels',
'canDeleteTrainedModels',
'canStartStopTrainedModels',
],
};
13 changes: 4 additions & 9 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import React, { type FC, useMemo } from 'react';
import './_index.scss';
import ReactDOM from 'react-dom';
import { pick } from 'lodash';
import { AppMountParameters, CoreStart, HttpStart } from '@kbn/core/public';

import type { AppMountParameters, CoreStart, HttpStart } from '@kbn/core/public';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { Storage } from '@kbn/kibana-utils-plugin/public';
Expand All @@ -33,6 +34,7 @@ import { mlUsageCollectionProvider } from './services/usage_collection';
import { MlRouter } from './routing';
import { mlApiServicesProvider } from './services/ml_api_service';
import { HttpService } from './services/http_service';
import type { PageDependencies } from './routing/router';

export type MlDependencies = Omit<
MlSetupDependencies,
Expand All @@ -48,12 +50,6 @@ interface AppProps {

const localStorage = new Storage(window.localStorage);

// temporary function to hardcode the serverless state
// this will be replaced by the true serverless information from kibana
export function isServerless() {
return false;
}

/**
* Provides global services available across the entire ML app.
*/
Expand All @@ -65,7 +61,6 @@ export function getMlGlobalServices(httpStart: HttpStart, usageCollection?: Usag
httpService,
mlApiServices,
mlUsageCollection: mlUsageCollectionProvider(usageCollection),
isServerless,
mlCapabilities: new MlCapabilitiesService(mlApiServices),
mlLicense: new MlLicense(),
};
Expand All @@ -78,7 +73,7 @@ export interface MlServicesContext {
export type MlGlobalServices = ReturnType<typeof getMlGlobalServices>;

const App: FC<AppProps> = ({ coreStart, deps, appMountParams }) => {
const pageDeps = {
const pageDeps: PageDependencies = {
history: appMountParams.history,
setHeaderActionMenu: appMountParams.setHeaderActionMenu,
setBreadcrumbs: coreStart.chrome!.setBreadcrumbs,
Expand Down
Loading