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

[eem] _search endpoint / initial entity manager UI #199609

Merged
merged 47 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cbc7c06
initial commit
klacabane Nov 11, 2024
6f10eb4
unneeded array.from
klacabane Nov 11, 2024
2092eda
should not be added
klacabane Nov 11, 2024
87a3c55
tweaks
klacabane Nov 12, 2024
63ce569
include es metadata
klacabane Nov 12, 2024
79338d8
slice result set
klacabane Nov 12, 2024
2df44ce
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 18, 2024
69b4900
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 18, 2024
4f9aca5
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Nov 18, 2024
31640ed
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 18, 2024
8926c24
fix imports and add @timestamp as required field
klacabane Nov 18, 2024
fcfc507
configurable timestamp
klacabane Nov 18, 2024
1678d83
mandatory timestamp field
klacabane Nov 18, 2024
6d80b81
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Nov 18, 2024
5449825
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 18, 2024
7451b89
fetch sources from kibana_entity_definitions
klacabane Nov 19, 2024
83db43a
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Nov 19, 2024
40b4dc7
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 19, 2024
6f07b1c
move ui to entity_manager_app
klacabane Nov 19, 2024
2872334
add start/end to _search
klacabane Nov 19, 2024
a64dccf
non optional start/end
klacabane Nov 19, 2024
00c0ec8
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 19, 2024
39f7758
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Nov 19, 2024
535622e
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Nov 19, 2024
1a02de8
add timestamp_field to form
klacabane Nov 19, 2024
820f381
fix configs
klacabane Nov 19, 2024
19b6bb6
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 19, 2024
832297e
remove usagecollection
klacabane Nov 20, 2024
59ab759
register entity_manager in application_usage
klacabane Nov 20, 2024
6035b27
update oss_plugins
klacabane Nov 20, 2024
698debf
remove queryclient
klacabane Nov 20, 2024
7616c10
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 20, 2024
506ce78
fix merge and tests
klacabane Nov 20, 2024
ad1c530
query test
klacabane Nov 20, 2024
48add74
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 20, 2024
720d421
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 21, 2024
79a1c20
Update x-pack/plugins/entity_manager/server/lib/queries/index.test.ts
klacabane Nov 21, 2024
9a14b77
Update x-pack/plugins/entity_manager/server/lib/queries/utils.test.ts
klacabane Nov 21, 2024
26bf3d8
add type level metadata/filters
klacabane Nov 21, 2024
5898952
v2 routes
klacabane Nov 21, 2024
baab5b3
add searchEntitiesBySources
klacabane Nov 21, 2024
51af524
update search module path
klacabane Nov 21, 2024
a1ae809
types
klacabane Nov 21, 2024
67902d9
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 21, 2024
2606a06
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 21, 2024
f904abb
rename entityv2
klacabane Nov 22, 2024
a49c97e
Merge branch 'main' into 188-entity-definition-v2-type-source
klacabane Nov 22, 2024
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
7 changes: 7 additions & 0 deletions x-pack/packages/kbn-entities-schema/src/schema/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export interface MetadataRecord {
[key: string]: string[] | MetadataRecord | string;
}

export interface Entity {
klacabane marked this conversation as resolved.
Show resolved Hide resolved
'entity.id': string;
'entity.last_seen_timestamp': string;
'entity.type': string;
[metadata: string]: any;
}

const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
type Literal = z.infer<typeof literalSchema>;
type Metadata = Literal | { [key: string]: Metadata } | Metadata[];
Expand Down
26 changes: 24 additions & 2 deletions x-pack/plugins/entity_manager/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,31 @@
"plugin": {
"id": "entityManager",
"configPath": ["xpack", "entityManager"],
"requiredPlugins": ["security", "encryptedSavedObjects", "licensing"],
"browser": true,
"server": true,
"requiredBundles": []
"requiredPlugins": [
"data",
"dataViews",
"dataViewEditor",
"dataViewFieldEditor",
"security",
"encryptedSavedObjects",
"lens",
"observability",
"observabilityShared",
"embeddable",
"presentationUtil",
"usageCollection",
"licensing",
"transform"
],
"optionalPlugins": [
"cloud",
"serverless"
],
"requiredBundles": [
"kibanaReact",
"kibanaUtils"
]
}
}
134 changes: 134 additions & 0 deletions x-pack/plugins/entity_manager/public/application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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 { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public';
import { PerformanceContextProvider } from '@kbn/ebt-tools';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';
import ReactDOM from 'react-dom';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { Route, Router, Routes } from '@kbn/shared-ux-router';
import { PluginContext } from './context/plugin_context';
import { EntityManagerPluginStart } from './types';
import { getRoutes } from './routes';
import { EntityClient } from './lib/entity_client';
import { EntityManagerOverviewPage } from './pages/overview';

function App() {
const routes = getRoutes();
return (
<Routes>
{Object.keys(routes).map((path) => {
const { handler, exact } = routes[path];
const Wrapper = () => handler();
return <Route key={path} path={path} exact={exact} component={Wrapper} />;
})}
</Routes>
);
}

export function renderApp({
core,
plugins,
appMountParameters,
ObservabilityPageTemplate,
usageCollection,
isDev,
kibanaVersion,
isServerless,
entityClient,
}: {
core: CoreStart;
plugins: EntityManagerPluginStart;
appMountParameters: AppMountParameters;
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
usageCollection: UsageCollectionSetup;
isDev?: boolean;
kibanaVersion: string;
isServerless?: boolean;
entityClient: EntityClient;
}) {
const { element, history, theme$ } = appMountParameters;
const isDarkMode = core.theme.getTheme().darkMode;

// ensure all divs are .kbnAppWrappers
element.classList.add(APP_WRAPPER_CLASS);

const queryClient = new QueryClient();

const ApplicationUsageTrackingProvider =
usageCollection?.components.ApplicationUsageTrackingProvider ?? React.Fragment;

const CloudProvider = plugins.cloud?.CloudContextProvider ?? React.Fragment;

const PresentationContextProvider = React.Fragment;

ReactDOM.render(
<KibanaRenderContextProvider {...core}>
<PresentationContextProvider>
<ApplicationUsageTrackingProvider>
<KibanaThemeProvider {...{ theme: { theme$ } }}>
<CloudProvider>
<KibanaContextProvider
services={{
...core,
...plugins,
storage: new Storage(localStorage),
entityClient: new EntityClient(core),
isDev,
kibanaVersion,
isServerless,
}}
>
<PluginContext.Provider
value={{
isDev,
isServerless,
appMountParameters,
ObservabilityPageTemplate,
entityClient,
}}
>
<Router history={history}>
<EuiThemeProvider darkMode={isDarkMode}>
<RedirectAppLinks
coreStart={core}
data-test-subj="observabilityMainContainer"
>
<PerformanceContextProvider>
<QueryClientProvider client={queryClient}>
<EntityManagerOverviewPage />
</QueryClientProvider>
</PerformanceContextProvider>
</RedirectAppLinks>
</EuiThemeProvider>
</Router>
</PluginContext.Provider>
</KibanaContextProvider>
</CloudProvider>
</KibanaThemeProvider>
</ApplicationUsageTrackingProvider>
</PresentationContextProvider>
</KibanaRenderContextProvider>,
element
);

return () => {
// This needs to be present to fix https://github.com/elastic/kibana/issues/155704
// as the Overview page renders the UX Section component. That component renders a Lens embeddable
// via the ExploratoryView app, which uses search sessions. Therefore on unmounting we need to clear
// these sessions.
plugins.data.search.session.clear();
ReactDOM.unmountComponentAtNode(element);
};
}
21 changes: 21 additions & 0 deletions x-pack/plugins/entity_manager/public/context/plugin_context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { createContext } from 'react';
import type { AppMountParameters } from '@kbn/core/public';
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
import { EntityClient } from '../lib/entity_client';

export interface PluginContextValue {
isDev?: boolean;
isServerless?: boolean;
appMountParameters?: AppMountParameters;
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
entityClient: EntityClient;
}

export const PluginContext = createContext<PluginContextValue | null>(null);
22 changes: 22 additions & 0 deletions x-pack/plugins/entity_manager/public/hooks/use_kibana.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { CoreStart } from '@kbn/core/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { EntityClient } from '../lib/entity_client';

export type StartServices<AdditionalServices extends object = {}> = CoreStart &
AdditionalServices & {
storage: Storage;
kibanaVersion: string;
entityClient: EntityClient;
};
const useTypedKibana = <AdditionalServices extends object = {}>() =>
useKibana<StartServices<AdditionalServices>>();

export { useTypedKibana as useKibana };
19 changes: 19 additions & 0 deletions x-pack/plugins/entity_manager/public/hooks/use_plugin_context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 { useContext } from 'react';
import { PluginContext } from '../context/plugin_context';
import type { PluginContextValue } from '../context/plugin_context';

export function usePluginContext(): PluginContextValue {
const context = useContext(PluginContext);
if (!context) {
throw new Error('Plugin context value is missing!');
}

return context;
}
Loading