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

New Integration Assistant plugin #184296

Merged
merged 101 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
f1452a5
stashing changes
P1llus May 24, 2024
071b330
remove unecessary api code and update placeholder services
P1llus May 24, 2024
d102b28
update types, remove more code that is not needed anymore
P1llus May 24, 2024
b89cf96
cleaning up a lot of old code, reformat for kibana etc
P1llus May 24, 2024
84c58d4
fixing import paths
P1llus May 24, 2024
4e6a6bb
adding license headers and fixing last type paths
P1llus May 24, 2024
1da8c88
adding template files and more cleanup
P1llus May 25, 2024
9bc9dbf
adding templates, removing pages, adding some test buttons
P1llus May 25, 2024
813e342
stashing changes
P1llus May 25, 2024
540882c
stashing many changes with a non-descriptive commit message :)
P1llus May 26, 2024
58ad9f5
adding some fix to build integration api, starting on tests
P1llus May 27, 2024
eeb253d
adding some basic styling and conditions to test UI buttons
P1llus May 27, 2024
a4057b0
adding some small fixes
P1llus May 27, 2024
49f9db3
adding some initial jest tests
P1llus May 27, 2024
6659c9f
typo
patrykkopycinski May 27, 2024
83c6ee2
adding tests for ecs graph
P1llus May 27, 2024
0dd0851
split handleValidatePipeline to new file for mocks, added initial tes…
P1llus May 29, 2024
9e5fa1d
updating existing and adding new tests for backend, add esclient from…
P1llus May 29, 2024
2c54358
added context to related routes
P1llus May 29, 2024
6aefd4f
disable config by default
semd May 30, 2024
8e641b4
log debug
semd May 30, 2024
7c1ca51
Merge branch 'main' into integration_assistant
kibanamachine May 30, 2024
819374b
Add testpipeline API, update testPipeline to allow passing client as …
P1llus May 30, 2024
2bc589d
remove yarn.lock created by accident, add support for testing/updatin…
P1llus May 30, 2024
88a61bc
use actionsclient
patrykkopycinski May 30, 2024
24efa82
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
patrykkopycinski May 30, 2024
37815f3
removing the public folder and disable UI, will provide in separate PR
P1llus May 31, 2024
4d127ee
Merge branch 'main' into integration_assistant
kibanamachine May 31, 2024
f576253
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 31, 2024
ca5ca42
Adding some minor route argument changes
P1llus May 31, 2024
696b170
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine May 31, 2024
044ca8a
update readme
P1llus May 31, 2024
ba3b3e5
Update file operations to be sync rather than async as they have to b…
P1llus May 31, 2024
2985be8
Merge branch 'main' into integration_assistant
kibanamachine May 31, 2024
b78e00a
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine May 31, 2024
728a3d9
removing reference to local bedrock model in tests
P1llus May 31, 2024
1e005ef
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
P1llus May 31, 2024
1461631
Merge branch 'main' into integration_assistant
kibanamachine May 31, 2024
a3da613
fix create router type for backend
P1llus May 31, 2024
71725fd
renamed all template files to pass linter checks
P1llus May 31, 2024
1351f97
Merge branch 'main' into integration_assistant
P1llus May 31, 2024
4242078
revert commented out request validation
P1llus May 31, 2024
62668fe
fix sending object instead of string to missing keys prompt
P1llus May 31, 2024
d238614
Skip fields_to_remove if an empty array
bhapas Jun 3, 2024
ee12e81
Merge remote-tracking branch 'upstream/main' into integration_assistant
bhapas Jun 3, 2024
be0289c
conflicts solved
semd Jun 3, 2024
4338c97
Merge branch 'main' into integration_assistant
kibanamachine Jun 3, 2024
c2332dd
Merge branch 'main' into integration_assistant
patrykkopycinski Jun 3, 2024
a568780
fix
patrykkopycinski Jun 3, 2024
c3ab152
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
patrykkopycinski Jun 3, 2024
b79d05c
Update docs
bhapas Jun 4, 2024
abb17ce
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
bhapas Jun 4, 2024
bbd749e
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
ead0fd6
Update yarn.lock
bhapas Jun 4, 2024
3d518bd
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
378e17b
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
9fa57d2
fix changed FakeListLLM to FakeStreamingLLM
bhapas Jun 4, 2024
0ef31c4
Merge branch 'main' into integration_assistant
kibanamachine Jun 4, 2024
687bd94
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
bhapas Jun 4, 2024
498556e
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
d1f0667
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
a3aac1f
Add integration_assistant to eslint
bhapas Jun 4, 2024
a337e06
Merge branch 'main' into integration_assistant
bhapas Jun 4, 2024
1b23cd2
Fix files with eslint issues
bhapas Jun 4, 2024
7cb7799
Use SimpleChatModel
patrykkopycinski Jun 4, 2024
9aac53e
Merge branch 'integration_assistant' of github.com:P1llus/kibana into…
patrykkopycinski Jun 4, 2024
e32fc9d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 4, 2024
c5678e3
[CI] Auto-commit changed files from 'yarn openapi:generate'
kibanamachine Jun 4, 2024
bce115d
fix
patrykkopycinski Jun 4, 2024
d42f6fd
fix eslint issue
bhapas Jun 5, 2024
8e6d180
Merge branch 'main' into integration_assistant
bhapas Jun 5, 2024
a5db6d2
Merge branch 'main' into integration_assistant
bhapas Jun 5, 2024
4488364
Merge branch 'main' into integration_assistant
bhapas Jun 5, 2024
e0b9cd8
Add versioned routes and make the APIs internal
bhapas Jun 7, 2024
6d8a9a4
Merge branch 'main' into integration_assistant
bhapas Jun 7, 2024
2367be8
Remove unnecessary addition in package.json
bhapas Jun 7, 2024
0cadcc0
update yarn.lock
bhapas Jun 7, 2024
b930406
Merge branch 'main' into integration_assistant
bhapas Jun 7, 2024
317db28
Merge branch 'main' into integration_assistant
bhapas Jun 10, 2024
32ebbf1
Merge remote-tracking branch 'upstream/main' into integration_assistant
bhapas Jun 10, 2024
4ce2877
Revert unnecessary changes
bhapas Jun 10, 2024
ecd4593
Merge branch 'main' into integration_assistant
bhapas Jun 10, 2024
4e4779c
[CI] Auto-commit changed files from 'yarn openapi:generate'
kibanamachine Jun 10, 2024
e1df3e6
Merge branch 'main' into integration_assistant
kibanamachine Jun 10, 2024
b37688f
Revert eslint changes
bhapas Jun 10, 2024
b2ae8fe
Merge branch 'main' into integration_assistant
kibanamachine Jun 10, 2024
980995a
Merge branch 'main' into integration_assistant
bhapas Jun 11, 2024
6160ba6
Merge branch 'main' into integration_assistant
kibanamachine Jun 11, 2024
40408ff
Use SimpleChatModel
bhapas Jun 11, 2024
ad8417f
Update yarn.lock
bhapas Jun 11, 2024
f67cffa
Merge branch 'main' into integration_assistant
kibanamachine Jun 12, 2024
a10dce0
Disable the feature by default
bhapas Jun 12, 2024
499b424
Merge branch 'main' into integration_assistant
kibanamachine Jun 12, 2024
df8dbc5
test
patrykkopycinski Jun 12, 2024
fc15ed1
fix
patrykkopycinski Jun 12, 2024
efcb60a
Merge branch 'main' into integration_assistant
kibanamachine Jun 13, 2024
f5b7853
Ignore building system tests for custom packages
bhapas Jun 13, 2024
c5d827a
Merge branch 'main' into integration_assistant
kibanamachine Jun 13, 2024
77214b0
bump langgraph
patrykkopycinski Jun 13, 2024
3492c88
revert
patrykkopycinski Jun 13, 2024
360f840
Merge branch 'main' into integration_assistant
kibanamachine Jun 13, 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
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,29 @@ module.exports = {
},
},

/**
* Integration assistant overrides
*/
{
// front end and common typescript and javascript files only
files: [
'x-pack/plugins/integration_assistant/public/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/integration_assistant/common/**/*.{js,mjs,ts,tsx}',
],
rules: {
'import/no-nodejs-modules': 'error',
'no-duplicate-imports': 'off',
'@typescript-eslint/no-duplicate-imports': 'error',
'no-restricted-imports': [
'error',
{
// prevents UI code from importing server side code and then webpack including it when doing builds
patterns: ['**/server/*'],
},
],
},
},

/**
* ML overrides
*/
Expand Down Expand Up @@ -1068,6 +1091,7 @@ module.exports = {
files: [
'x-pack/plugins/ecs_data_quality_dashboard/**/*.{ts,tsx}',
'x-pack/plugins/elastic_assistant/**/*.{ts,tsx}',
'x-pack/plugins/integration_assistant/**/*.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant/**/*.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant-common/**/*.{ts,tsx}',
'x-pack/packages/kbn-langchain/**/*.{ts,tsx}',
Expand All @@ -1082,6 +1106,7 @@ module.exports = {
excludedFiles: [
'x-pack/plugins/ecs_data_quality_dashboard/**/*.{test,mock,test_helper}.{ts,tsx}',
'x-pack/plugins/elastic_assistant/**/*.{test,mock,test_helper}.{ts,tsx}',
'x-pack/plugins/integration_assistant/**/*.{test,mock,test_helper}.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant/**/*.{test,mock,test_helper}.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant-common/**/*.{test,mock,test_helper}.{ts,tsx}',
'x-pack/packages/kbn-langchain/**/*.{test,mock,test_helper}.{ts,tsx}',
Expand All @@ -1102,6 +1127,7 @@ module.exports = {
files: [
'x-pack/plugins/ecs_data_quality_dashboard/**/*.{ts,tsx}',
'x-pack/plugins/elastic_assistant/**/*.{ts,tsx}',
'x-pack/plugins/integration_assistant/**/*.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant/**/*.{ts,tsx}',
'x-pack/packages/kbn-elastic-assistant-common/**/*.{ts,tsx}',
'x-pack/packages/kbn-langchain/**/*.{ts,tsx}',
Expand Down Expand Up @@ -1141,6 +1167,7 @@ module.exports = {
files: [
'x-pack/plugins/ecs_data_quality_dashboard/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/elastic_assistant/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/integration_assistant/**/*.{js,mjs,ts,tsx}',
'x-pack/packages/kbn-elastic-assistant/**/*.{js,mjs,ts,tsx}',
'x-pack/packages/kbn-elastic-assistant-common/**/*.{js,mjs,ts,tsx}',
'x-pack/packages/kbn-langchain/**/*.{js,mjs,ts,tsx}',
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ x-pack/plugins/observability_solution/infra @elastic/obs-ux-logs-team @elastic/o
x-pack/plugins/ingest_pipelines @elastic/kibana-management
src/plugins/input_control_vis @elastic/kibana-presentation
src/plugins/inspector @elastic/kibana-presentation
x-pack/plugins/integration_assistant @elastic/security-solution
src/plugins/interactive_setup @elastic/kibana-security
test/interactive_setup_api_integration/plugins/test_endpoints @elastic/kibana-security
packages/kbn-interpreter @elastic/kibana-visualizations
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ the infrastructure monitoring use-case within Kibana.
|The ingest_pipelines plugin provides Kibana support for Elasticsearch's ingest pipelines.


|{kib-repo}blob/{branch}/x-pack/plugins/integration_assistant/README.md[integrationAssistant]
|Team owner: Security Integrations Scalability


|{kib-repo}blob/{branch}/x-pack/plugins/observability_solution/investigate/README.md[investigate]
|undefined

Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"resolutions": {
"**/@bazel/typescript/protobufjs": "6.11.4",
"**/@hello-pangea/dnd": "16.6.0",
"**/@langchain/core": "0.1.53",
"**/@langchain/core": "0.2.3",
"**/@types/node": "20.10.5",
"**/@typescript-eslint/utils": "5.62.0",
"**/chokidar": "^3.5.3",
Expand Down Expand Up @@ -540,6 +540,7 @@
"@kbn/ingest-pipelines-plugin": "link:x-pack/plugins/ingest_pipelines",
"@kbn/input-control-vis-plugin": "link:src/plugins/input_control_vis",
"@kbn/inspector-plugin": "link:src/plugins/inspector",
"@kbn/integration-assistant-plugin": "link:x-pack/plugins/integration_assistant",
"@kbn/interactive-setup-plugin": "link:src/plugins/interactive_setup",
"@kbn/interactive-setup-test-endpoints-plugin": "link:test/interactive_setup_api_integration/plugins/test_endpoints",
"@kbn/interpreter": "link:packages/kbn-interpreter",
Expand Down Expand Up @@ -924,9 +925,10 @@
"@kbn/watcher-plugin": "link:x-pack/plugins/watcher",
"@kbn/xstate-utils": "link:packages/kbn-xstate-utils",
"@kbn/zod-helpers": "link:packages/kbn-zod-helpers",
"@langchain/community": "^0.0.44",
"@langchain/core": "^0.1.53",
"@langchain/openai": "^0.0.25",
"@langchain/community": "^0.2.4",
"@langchain/core": "0.2.3",
"@langchain/langgraph": "^0.0.21",
"@langchain/openai": "^0.0.34",
"@langtrase/trace-attributes": "^3.0.8",
"@langtrase/typescript-sdk": "^2.2.1",
"@launchdarkly/node-server-sdk": "^9.4.5",
Expand All @@ -949,10 +951,10 @@
"@paralleldrive/cuid2": "^2.2.2",
"@reduxjs/toolkit": "1.9.7",
"@slack/webhook": "^7.0.1",
"@smithy/eventstream-codec": "^2.0.12",
"@smithy/eventstream-serde-node": "^2.1.1",
"@smithy/types": "^2.9.1",
"@smithy/util-utf8": "^2.0.0",
"@smithy/eventstream-codec": "^3.0.0",
"@smithy/eventstream-serde-node": "^3.0.0",
"@smithy/types": "^3.0.0",
"@smithy/util-utf8": "^3.0.0",
"@tanstack/react-query": "^4.29.12",
"@tanstack/react-query-devtools": "^4.29.12",
"@turf/along": "6.0.1",
Expand Down Expand Up @@ -1064,9 +1066,10 @@
"jsonwebtoken": "^9.0.2",
"jsts": "^1.6.2",
"kea": "^2.6.0",
"langchain": "^0.1.30",
"langsmith": "^0.1.14",
"langchain": "0.2.3",
"langsmith": "^0.1.30",
"launchdarkly-js-client-sdk": "^3.3.0",
"launchdarkly-node-server-sdk": "^7.0.3",
"load-json-file": "^6.2.0",
"lodash": "^4.17.21",
"lru-cache": "^4.1.5",
Expand All @@ -1089,6 +1092,7 @@
"node-forge": "^1.3.1",
"nodemailer": "^6.9.9",
"normalize-path": "^3.0.0",
"nunjucks": "^3.2.4",
"object-hash": "^1.3.1",
"object-path-immutable": "^3.1.1",
"openai": "^4.24.1",
Expand Down Expand Up @@ -1501,6 +1505,7 @@
"@types/node-forge": "^1.3.10",
"@types/nodemailer": "^6.4.0",
"@types/normalize-path": "^3.0.0",
"@types/nunjucks": "^3.2.6",
"@types/object-hash": "^1.3.0",
"@types/opn": "^5.1.0",
"@types/ora": "^1.3.5",
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@
"@kbn/input-control-vis-plugin/*": ["src/plugins/input_control_vis/*"],
"@kbn/inspector-plugin": ["src/plugins/inspector"],
"@kbn/inspector-plugin/*": ["src/plugins/inspector/*"],
"@kbn/integration-assistant-plugin": ["x-pack/plugins/integration_assistant"],
"@kbn/integration-assistant-plugin/*": ["x-pack/plugins/integration_assistant/*"],
"@kbn/interactive-setup-plugin": ["src/plugins/interactive_setup"],
"@kbn/interactive-setup-plugin/*": ["src/plugins/interactive_setup/*"],
"@kbn/interactive-setup-test-endpoints-plugin": ["test/interactive_setup_api_integration/plugins/test_endpoints"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ActionsClientChatOpenAIParams {
streaming?: boolean;
traceId?: string;
maxRetries?: number;
maxTokens?: number;
model?: string;
temperature?: number;
signal?: AbortSignal;
Expand Down Expand Up @@ -75,9 +76,11 @@ export class ActionsClientChatOpenAI extends ChatOpenAI {
streaming = true,
temperature,
timeout,
maxTokens,
}: ActionsClientChatOpenAIParams) {
super({
maxRetries,
maxTokens,
streaming,
// matters only for the LangSmith logs (Metadata > Invocation Params), which are misleading if this is not set
modelName: model ?? DEFAULT_OPEN_AI_MODEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface CustomChatModelInput extends BaseChatModelParams {
temperature?: number;
request: KibanaRequest;
streaming: boolean;
maxTokens?: number;
}

export class ActionsClientSimpleChatModel extends SimpleChatModel {
Expand All @@ -44,6 +45,7 @@ export class ActionsClientSimpleChatModel extends SimpleChatModel {
#request: KibanaRequest;
#traceId: string;
#signal?: AbortSignal;
#maxTokens?: number;
llmType: string;
streaming: boolean;
model?: string;
Expand All @@ -59,6 +61,7 @@ export class ActionsClientSimpleChatModel extends SimpleChatModel {
temperature,
signal,
streaming,
maxTokens,
}: CustomChatModelInput) {
super({});

Expand All @@ -68,6 +71,7 @@ export class ActionsClientSimpleChatModel extends SimpleChatModel {
this.#logger = logger;
this.#signal = signal;
this.#request = request;
this.#maxTokens = maxTokens;
this.llmType = llmType ?? 'ActionsClientSimpleChatModel';
this.model = model;
this.temperature = temperature;
Expand Down Expand Up @@ -95,7 +99,7 @@ export class ActionsClientSimpleChatModel extends SimpleChatModel {
throw new Error('No messages provided.');
}
const formattedMessages = [];
if (messages.length === 2) {
if (messages.length >= 2) {
spong marked this conversation as resolved.
Show resolved Hide resolved
messages.forEach((message, i) => {
if (typeof message.content !== 'string') {
throw new Error('Multimodal messages are not supported.');
Expand All @@ -121,6 +125,7 @@ export class ActionsClientSimpleChatModel extends SimpleChatModel {
subActionParams: {
model: this.model,
messages: formattedMessages,
maxTokens: this.#maxTokens,
...getDefaultArguments(this.llmType, this.temperature, options.stop),
},
},
Expand Down

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

66 changes: 66 additions & 0 deletions x-pack/plugins/integration_assistant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Integration Assistant

## Overview

Team owner: Security Integrations Scalability

This is a new Kibana plugin created to help users with automatically generating integration packages based on provided log samples and relevant information

## Features

Exposes 4 API's that can be consumed by any frontend plugin, which are:

- ECS Mapping API
- Categorization API
- Related Fields API
- Build Integration API
- Optional Test Pipeline API (Used to update pipeline results if the ingest pipeline is changed by a user in the UI).

## Development

### Backend

#### Overview

The backend part of the plugin utilizes langraph extensively to parse the provided log samples and generate the integration package.

One instance of langraph is created that will include one or more `nodes` in which each node represents a step in the integration package generation process.

Each node links to a specific function, usually a `handler` specified in its own file under each graph folder that will be executed when the node is reached.

#### Structure

**Graphs**

The graph components are split into logical parts and are placed in separate folders for each graph under the `./server/graphs` directory.

Each graph folder needs to contains at least one `graph.ts`, which exports a function that returns the compiled graph object.

Each exported graph function is then linked up to one or more API routes.

**Routes**

All routes are defined under `./server/routes` in its own file, and then included in the `./server/routes/register_routes.ts` file.

**Integration Builder**

The integration builder is the last step in the expected API flow (ECS Mapping -> Categorization -> Related Fields -> Integration Builder).
With the provided package and data stream details, an optional logo and a list of sample logs, the API will build out the entire folder structure and files required for the integration package, archive it and return it as a `Buffer`.

**Templates**

Currently the templates are stored as `nunjucks` files as they were converted from `jinja2` templates, which use the exact same format. Longer term this will most likely be switched to the Kibana forked Handlebars templating engine.

The templates are stored in the `./server/templates` directory and are used to generate the integration package files while running the Integration Builder API.

One template (pipeline.yml.njk) is used by the ECS Mapping API to generate the boilerplate ingest pipeline structure we want to use for all generated integrations.

## Tests

All mocks/fixtures are placed in the top `./__jest__` directory of the plugin. If many mocks/fixtures are required, try to split them up into separate file(s).

Tests can be run with:

```bash
node scripts/jest x-pack/plugins/integration_assistant/ --coverage
```
Loading