Skip to content

[AI4DSOC] Alert Flyout#218018

Merged
PhilippeOberti merged 80 commits intoelastic:mainfrom
stephmilovic:ai_for_soc_flyout
Apr 18, 2025
Merged

[AI4DSOC] Alert Flyout#218018
PhilippeOberti merged 80 commits intoelastic:mainfrom
stephmilovic:ai_for_soc_flyout

Conversation

@stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Apr 11, 2025

Summary

Alert flyout for AI for the SOC.
Screenshot 2025-04-11 at 12 15 22 PM

The flyout sections include:

  • New header highlighting the integration source
    Screenshot 2025-04-11 at 12 16 00 PM

  • AI generated alert summary generated by button (Generate or Regenerate). Stored in a new data stream (.kibana-elastic-ai-assistant-alert-summary-*)
    Screenshot 2025-04-11 at 12 15 55 PM

  • Anonymization toggle for the alert summary is located in the flyout gear settings menu
    Screenshot 2025-04-11 at 12 32 45 PM

  • Highlighted fields
    Screenshot 2025-04-11 at 12 15 52 PM

  • Attack discovery MiniAttackChain (currently hardcoded to a preconfigured connector, waiting for further work from @andrew-goldstein to hook up to actual alert related AD)
    Screenshot 2025-04-11 at 12 15 36 PM

  • Conversations dropdown that show any conversations this alert is referenced
    Screenshot 2025-04-11 at 12 18 03 PM

  • Suggested prompts that create a new conversation with the alert as context (copy pending)
    Screenshot 2025-04-11 at 12 18 09 PM

  • The connector used in the alert summary generation is selected in Stack Management > Advanced Settings > Security Solution > Default AI Connector (copy pending)
    Screenshot 2025-04-11 at 12 34 15 PM

New prompts

This PR adds 2 new prompts under a new promptGroupId.aiForSoc:
- promptDictionary.alertSummarySystemPrompt
- promptDictionary.alertSummary
In order to access these prompts in the proper spots, the new find alert summary route returns the "user" prompt (promptDictionary.alertSummary). In order to get the system prompt in place, we pass a promptIds object to the POST_ACTIONS_CONNECTOR_EXECUTE which is appended to the main system prompt

Testing

This needs to be ran in Serverless:

  • yarn es serverless --projectType security
  • yarn serverless-security --no-base-path

You also need to enable the AI for SOC tier, by adding the following to your serverless.security.dev.yml file:

xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]

Use one of these Serverless users:

  • platform_engineer
  • endpoint_operations_analyst
  • endpoint_policy_manager
  • admin
  • system_indices_superuser

Then:

  • generate data: yarn test:generate:serverless-dev
  • create 4 catch all rules, each with a name of a AI for SOC integration (google_secops, microsoft_sentinel,, sentinel_one and crowdstrike) => to do that you'll need to temporary comment the serverless.security.dev.yaml config changes as the rules page is not accessible in AI for SOC.
  • change this line to installedPackages: availablePackages to force having some packages installed
  • change this line to r.name === p.name to make sure there will be matches between integrations and rules

With this alerts data, you should be able to test each section of the flyout except the attack discovery widget, instructions for that are below.

Attack discovery widget

As I am waiting for updates from Andrew, currently the attack discovery widget looks up attack discoveries from a particular preconfigured connector. In order to test:

  1. Add preconfigured connector to your kibana.dev.yml: https://p.elstc.co/paste/J2qmGMeQ#GKSPhlggX4F93aUSKJsKpsqtCcyTepCkfJOEVxlZyfB
  2. Generate attack discovery with this connector
  3. Open the new flyout, you will see the attack discovery widget

Outstanding TODOs

These are all noted in the code

  1. Attack discovery widget is hardcoded to the preconfigured connector id. The widget should instead look up discoveries by alert ID, pending work from @andrew-goldstein
  2. Update copy for suggested prompts
  3. Update copy for ai connector UI setting
  4. Update AI connector UI setting to default to Elastic Managed LLM once it is fully available in serverless

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed a wrong usage of DocumentDetailsContextProvider, I'm blocking the PR just to be sure and I'm working on replacing it with the AIForSocContextProvider. This requires making some changes to the HighlightedFields component and will require testing in the alerts page flyout

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the Threat Hunting Investigations team!

@elasticmachine
Copy link
Contributor

elasticmachine commented Apr 17, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
automaticImport 731 752 +21
securitySolution 7234 7259 +25
total +46

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/elastic-assistant 141 145 +4
@kbn/elastic-assistant-common 517 526 +9
total +13

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
advancedSettings 36.8KB 37.1KB +331.0B
apm 2.5MB 2.5MB +331.0B
infra 1.2MB 1.2MB +331.0B
observabilityAiAssistantManagement 81.0KB 81.3KB +331.0B
profiling 372.8KB 373.1KB +331.0B
securitySolution 9.0MB 9.0MB +26.9KB
telemetryManagementSection 31.4KB 31.8KB +329.0B
total +28.8KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/elastic-assistant-common 0 1 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 89.4KB 89.5KB +46.0B
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 170 178 +8
@kbn/elastic-assistant-common 606 617 +11
total +19

ESLint disabled line counts

id before after diff
@kbn/elastic-assistant 13 14 +1
elasticAssistant 34 37 +3
total +4

Total ESLint disabled count

id before after diff
@kbn/elastic-assistant 14 15 +1
elasticAssistant 39 42 +3
total +4

History

@PhilippeOberti PhilippeOberti added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels labels Apr 17, 2025
@PhilippeOberti
Copy link
Contributor

run docs-build

@PhilippeOberti PhilippeOberti dismissed logeekal’s stale review April 18, 2025 00:54

The code that was modifying the alerts_context.tsx file has been reverted as it is not needed anymore.

@PhilippeOberti PhilippeOberti enabled auto-merge (squash) April 18, 2025 00:54
@PhilippeOberti PhilippeOberti merged commit ba0894d into elastic:main Apr 18, 2025
12 checks passed
davismcphee pushed a commit to davismcphee/kibana that referenced this pull request Apr 22, 2025
## Summary

Alert flyout for AI for the SOC. 
<img width="600" alt="Screenshot 2025-04-11 at 12 15 22 PM"
src="https://github.com/user-attachments/assets/fea2f7fb-7424-46b5-b9c2-5cafa336b0a9"
/>

### The flyout sections include:
- New header highlighting the integration source
<img width="596" alt="Screenshot 2025-04-11 at 12 16 00 PM"
src="https://github.com/user-attachments/assets/13033225-9e41-431f-8061-5df96a981665"
/>

- AI generated alert summary generated by button (Generate or
Regenerate). Stored in a new data stream
(`.kibana-elastic-ai-assistant-alert-summary-*`)
<img width="595" alt="Screenshot 2025-04-11 at 12 15 55 PM"
src="https://github.com/user-attachments/assets/ac835db2-2cbb-4a59-9e71-f1a9616a777f"
/>
- Anonymization toggle for the alert summary is located in the flyout
gear settings menu
<img width="270" alt="Screenshot 2025-04-11 at 12 32 45 PM"
src="https://github.com/user-attachments/assets/952936b9-571b-48e5-bd57-ecfd33855df3"
/>
- Highlighted fields
<img width="600" alt="Screenshot 2025-04-11 at 12 15 52 PM"
src="https://github.com/user-attachments/assets/3fccfab2-3e8b-4edc-adaf-3f320d9a5d20"
/>
- Attack discovery `MiniAttackChain` (currently hardcoded to a
preconfigured connector, waiting for further work from @andrew-goldstein
to hook up to actual alert related AD)
<img width="597" alt="Screenshot 2025-04-11 at 12 15 36 PM"
src="https://github.com/user-attachments/assets/d181f68d-5b77-4df4-a316-54e84d655a4c"
/>
- Conversations dropdown that show any conversations this alert is
referenced
<img width="601" alt="Screenshot 2025-04-11 at 12 18 03 PM"
src="https://github.com/user-attachments/assets/71d533d3-99b4-49c4-b336-05152fd64ed4"
/>
- Suggested prompts that create a new conversation with the alert as
context (_copy pending_)
<img width="594" alt="Screenshot 2025-04-11 at 12 18 09 PM"
src="https://github.com/user-attachments/assets/bca58f5a-f05c-4cdf-a466-0926c99e0ad6"
/>
- The connector used in the alert summary generation is selected in
Stack Management > Advanced Settings > Security Solution > Default AI
Connector (_copy pending_)
<img width="1163" alt="Screenshot 2025-04-11 at 12 34 15 PM"
src="https://github.com/user-attachments/assets/d2128497-22e4-4c14-b08c-991dc8287391"
/>

### New prompts
This PR adds 2 new prompts under a new `promptGroupId.aiForSoc`:
    - `promptDictionary.alertSummarySystemPrompt`
    - `promptDictionary.alertSummary`
In order to access these prompts in the proper spots, the new find alert
summary route returns the "user" prompt
(`promptDictionary.alertSummary`). In order to get the system prompt in
place, we pass a `promptIds` object to the
`POST_ACTIONS_CONNECTOR_EXECUTE` which is appended to the main system
prompt

## Testing

This needs to be ran in Serverless:
- `yarn es serverless --projectType security`
- `yarn serverless-security --no-base-path`

You also need to enable the AI for SOC tier, by adding the following to
your `serverless.security.dev.yml` file:
```
xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]
```

Use one of these Serverless users:
- `platform_engineer`
- `endpoint_operations_analyst`
- `endpoint_policy_manager`
- `admin`
- `system_indices_superuser`

Then:
- generate data: `yarn test:generate:serverless-dev`
- create 4 catch all rules, each with a name of a AI for SOC integration
(`google_secops`, `microsoft_sentinel`,, `sentinel_one` and
`crowdstrike`) => to do that you'll need to temporary comment the
`serverless.security.dev.yaml` config changes as the rules page is not
accessible in AI for SOC.
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_fetch_integrations.ts#L73)
to `installedPackages: availablePackages` to force having some packages
installed
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_integrations.ts#L63)
to `r.name === p.name` to make sure there will be matches between
integrations and rules

With this alerts data, you should be able to test each section of the
flyout _except_ the attack discovery widget, instructions for that are
below.

#### Attack discovery widget

As I am waiting for updates from Andrew, currently the attack discovery
widget looks up attack discoveries from a particular preconfigured
connector. In order to test:
1. Add preconfigured connector to your `kibana.dev.yml`:
https://p.elstc.co/paste/J2qmGMeQ#GKSPhlggX4F93aUSKJsKpsqtCcyTepCkfJOEVxlZyfB
2. Generate attack discovery with this connector
3. Open the new flyout, you will see the attack discovery widget

## Outstanding TODOs

These are all noted in the code
1. Attack discovery widget is hardcoded to the preconfigured connector
id. The widget should instead look up discoveries by alert ID, pending
work from @andrew-goldstein
2. Update copy for suggested prompts
3. Update copy for ai connector UI setting
4. Update AI connector UI setting to default to Elastic Managed LLM once
it is fully available in serverless

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: PhilippeOberti <philippe.oberti@elastic.co>
Co-authored-by: Angela Chuang <yi-chun.chuang@elastic.co>
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
## Summary

Alert flyout for AI for the SOC. 
<img width="600" alt="Screenshot 2025-04-11 at 12 15 22 PM"
src="https://github.com/user-attachments/assets/fea2f7fb-7424-46b5-b9c2-5cafa336b0a9"
/>

### The flyout sections include:
- New header highlighting the integration source
<img width="596" alt="Screenshot 2025-04-11 at 12 16 00 PM"
src="https://github.com/user-attachments/assets/13033225-9e41-431f-8061-5df96a981665"
/>

- AI generated alert summary generated by button (Generate or
Regenerate). Stored in a new data stream
(`.kibana-elastic-ai-assistant-alert-summary-*`)
<img width="595" alt="Screenshot 2025-04-11 at 12 15 55 PM"
src="https://github.com/user-attachments/assets/ac835db2-2cbb-4a59-9e71-f1a9616a777f"
/>
- Anonymization toggle for the alert summary is located in the flyout
gear settings menu
<img width="270" alt="Screenshot 2025-04-11 at 12 32 45 PM"
src="https://github.com/user-attachments/assets/952936b9-571b-48e5-bd57-ecfd33855df3"
/>
- Highlighted fields
<img width="600" alt="Screenshot 2025-04-11 at 12 15 52 PM"
src="https://github.com/user-attachments/assets/3fccfab2-3e8b-4edc-adaf-3f320d9a5d20"
/>
- Attack discovery `MiniAttackChain` (currently hardcoded to a
preconfigured connector, waiting for further work from @andrew-goldstein
to hook up to actual alert related AD)
<img width="597" alt="Screenshot 2025-04-11 at 12 15 36 PM"
src="https://github.com/user-attachments/assets/d181f68d-5b77-4df4-a316-54e84d655a4c"
/>
- Conversations dropdown that show any conversations this alert is
referenced
<img width="601" alt="Screenshot 2025-04-11 at 12 18 03 PM"
src="https://github.com/user-attachments/assets/71d533d3-99b4-49c4-b336-05152fd64ed4"
/>
- Suggested prompts that create a new conversation with the alert as
context (_copy pending_)
<img width="594" alt="Screenshot 2025-04-11 at 12 18 09 PM"
src="https://github.com/user-attachments/assets/bca58f5a-f05c-4cdf-a466-0926c99e0ad6"
/>
- The connector used in the alert summary generation is selected in
Stack Management > Advanced Settings > Security Solution > Default AI
Connector (_copy pending_)
<img width="1163" alt="Screenshot 2025-04-11 at 12 34 15 PM"
src="https://github.com/user-attachments/assets/d2128497-22e4-4c14-b08c-991dc8287391"
/>

### New prompts
This PR adds 2 new prompts under a new `promptGroupId.aiForSoc`:
    - `promptDictionary.alertSummarySystemPrompt`
    - `promptDictionary.alertSummary`
In order to access these prompts in the proper spots, the new find alert
summary route returns the "user" prompt
(`promptDictionary.alertSummary`). In order to get the system prompt in
place, we pass a `promptIds` object to the
`POST_ACTIONS_CONNECTOR_EXECUTE` which is appended to the main system
prompt

## Testing

This needs to be ran in Serverless:
- `yarn es serverless --projectType security`
- `yarn serverless-security --no-base-path`

You also need to enable the AI for SOC tier, by adding the following to
your `serverless.security.dev.yml` file:
```
xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]
```

Use one of these Serverless users:
- `platform_engineer`
- `endpoint_operations_analyst`
- `endpoint_policy_manager`
- `admin`
- `system_indices_superuser`

Then:
- generate data: `yarn test:generate:serverless-dev`
- create 4 catch all rules, each with a name of a AI for SOC integration
(`google_secops`, `microsoft_sentinel`,, `sentinel_one` and
`crowdstrike`) => to do that you'll need to temporary comment the
`serverless.security.dev.yaml` config changes as the rules page is not
accessible in AI for SOC.
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_fetch_integrations.ts#L73)
to `installedPackages: availablePackages` to force having some packages
installed
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_integrations.ts#L63)
to `r.name === p.name` to make sure there will be matches between
integrations and rules

With this alerts data, you should be able to test each section of the
flyout _except_ the attack discovery widget, instructions for that are
below.

#### Attack discovery widget

As I am waiting for updates from Andrew, currently the attack discovery
widget looks up attack discoveries from a particular preconfigured
connector. In order to test:
1. Add preconfigured connector to your `kibana.dev.yml`:
https://p.elstc.co/paste/J2qmGMeQ#GKSPhlggX4F93aUSKJsKpsqtCcyTepCkfJOEVxlZyfB
2. Generate attack discovery with this connector
3. Open the new flyout, you will see the attack discovery widget

## Outstanding TODOs

These are all noted in the code
1. Attack discovery widget is hardcoded to the preconfigured connector
id. The widget should instead look up discoveries by alert ID, pending
work from @andrew-goldstein
2. Update copy for suggested prompts
3. Update copy for ai connector UI setting
4. Update AI connector UI setting to default to Elastic Managed LLM once
it is fully available in serverless

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: PhilippeOberti <philippe.oberti@elastic.co>
Co-authored-by: Angela Chuang <yi-chun.chuang@elastic.co>
@PhilippeOberti
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

PhilippeOberti pushed a commit to PhilippeOberti/kibana that referenced this pull request Jun 4, 2025
## Summary

Alert flyout for AI for the SOC.
<img width="600" alt="Screenshot 2025-04-11 at 12 15 22 PM"
src="https://github.com/user-attachments/assets/fea2f7fb-7424-46b5-b9c2-5cafa336b0a9"
/>

### The flyout sections include:
- New header highlighting the integration source
<img width="596" alt="Screenshot 2025-04-11 at 12 16 00 PM"
src="https://github.com/user-attachments/assets/13033225-9e41-431f-8061-5df96a981665"
/>

- AI generated alert summary generated by button (Generate or
Regenerate). Stored in a new data stream
(`.kibana-elastic-ai-assistant-alert-summary-*`)
<img width="595" alt="Screenshot 2025-04-11 at 12 15 55 PM"
src="https://github.com/user-attachments/assets/ac835db2-2cbb-4a59-9e71-f1a9616a777f"
/>
- Anonymization toggle for the alert summary is located in the flyout
gear settings menu
<img width="270" alt="Screenshot 2025-04-11 at 12 32 45 PM"
src="https://github.com/user-attachments/assets/952936b9-571b-48e5-bd57-ecfd33855df3"
/>
- Highlighted fields
<img width="600" alt="Screenshot 2025-04-11 at 12 15 52 PM"
src="https://github.com/user-attachments/assets/3fccfab2-3e8b-4edc-adaf-3f320d9a5d20"
/>
- Attack discovery `MiniAttackChain` (currently hardcoded to a
preconfigured connector, waiting for further work from @andrew-goldstein
to hook up to actual alert related AD)
<img width="597" alt="Screenshot 2025-04-11 at 12 15 36 PM"
src="https://github.com/user-attachments/assets/d181f68d-5b77-4df4-a316-54e84d655a4c"
/>
- Conversations dropdown that show any conversations this alert is
referenced
<img width="601" alt="Screenshot 2025-04-11 at 12 18 03 PM"
src="https://github.com/user-attachments/assets/71d533d3-99b4-49c4-b336-05152fd64ed4"
/>
- Suggested prompts that create a new conversation with the alert as
context (_copy pending_)
<img width="594" alt="Screenshot 2025-04-11 at 12 18 09 PM"
src="https://github.com/user-attachments/assets/bca58f5a-f05c-4cdf-a466-0926c99e0ad6"
/>
- The connector used in the alert summary generation is selected in
Stack Management > Advanced Settings > Security Solution > Default AI
Connector (_copy pending_)
<img width="1163" alt="Screenshot 2025-04-11 at 12 34 15 PM"
src="https://github.com/user-attachments/assets/d2128497-22e4-4c14-b08c-991dc8287391"
/>

### New prompts
This PR adds 2 new prompts under a new `promptGroupId.aiForSoc`:
    - `promptDictionary.alertSummarySystemPrompt`
    - `promptDictionary.alertSummary`
In order to access these prompts in the proper spots, the new find alert
summary route returns the "user" prompt
(`promptDictionary.alertSummary`). In order to get the system prompt in
place, we pass a `promptIds` object to the
`POST_ACTIONS_CONNECTOR_EXECUTE` which is appended to the main system
prompt

## Testing

This needs to be ran in Serverless:
- `yarn es serverless --projectType security`
- `yarn serverless-security --no-base-path`

You also need to enable the AI for SOC tier, by adding the following to
your `serverless.security.dev.yml` file:
```
xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]
```

Use one of these Serverless users:
- `platform_engineer`
- `endpoint_operations_analyst`
- `endpoint_policy_manager`
- `admin`
- `system_indices_superuser`

Then:
- generate data: `yarn test:generate:serverless-dev`
- create 4 catch all rules, each with a name of a AI for SOC integration
(`google_secops`, `microsoft_sentinel`,, `sentinel_one` and
`crowdstrike`) => to do that you'll need to temporary comment the
`serverless.security.dev.yaml` config changes as the rules page is not
accessible in AI for SOC.
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_fetch_integrations.ts#L73)
to `installedPackages: availablePackages` to force having some packages
installed
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_integrations.ts#L63)
to `r.name === p.name` to make sure there will be matches between
integrations and rules

With this alerts data, you should be able to test each section of the
flyout _except_ the attack discovery widget, instructions for that are
below.

#### Attack discovery widget

As I am waiting for updates from Andrew, currently the attack discovery
widget looks up attack discoveries from a particular preconfigured
connector. In order to test:
1. Add preconfigured connector to your `kibana.dev.yml`:
https://p.elstc.co/paste/J2qmGMeQ#GKSPhlggX4F93aUSKJsKpsqtCcyTepCkfJOEVxlZyfB
2. Generate attack discovery with this connector
3. Open the new flyout, you will see the attack discovery widget

## Outstanding TODOs

These are all noted in the code
1. Attack discovery widget is hardcoded to the preconfigured connector
id. The widget should instead look up discoveries by alert ID, pending
work from @andrew-goldstein
2. Update copy for suggested prompts
3. Update copy for ai connector UI setting
4. Update AI connector UI setting to default to Elastic Managed LLM once
it is fully available in serverless

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: PhilippeOberti <philippe.oberti@elastic.co>
Co-authored-by: Angela Chuang <yi-chun.chuang@elastic.co>
(cherry picked from commit ba0894d)

# Conflicts:
#	x-pack/platform/packages/shared/kbn-elastic-assistant-common/constants.ts
#	x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/common_attributes.gen.ts
#	x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/common_attributes.schema.yaml
#	x-pack/platform/packages/shared/kbn-elastic-assistant-common/index.ts
#	x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/use_send_message/index.tsx
#	x-pack/solutions/security/plugins/elastic_assistant/server/ai_assistant_service/index.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/local_prompt_object.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.test.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts
#	x-pack/solutions/security/plugins/elastic_assistant/server/routes/register_routes.ts
#	x-pack/solutions/security/plugins/security_solution/public/attack_discovery/pages/results/attack_discovery_panel/panel_header/summary_actions/mini_attack_chain/index.test.tsx
#	x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields.tsx
#	x-pack/solutions/security/plugins/security_solution/server/ui_settings.ts
#	x-pack/solutions/security/plugins/security_solution_serverless/tsconfig.json
stephmilovic added a commit to PhilippeOberti/kibana that referenced this pull request Jun 5, 2025
Alert flyout for AI for the SOC.
<img width="600" alt="Screenshot 2025-04-11 at 12 15 22 PM"
src="https://github.com/user-attachments/assets/fea2f7fb-7424-46b5-b9c2-5cafa336b0a9"
/>

- New header highlighting the integration source
<img width="596" alt="Screenshot 2025-04-11 at 12 16 00 PM"
src="https://github.com/user-attachments/assets/13033225-9e41-431f-8061-5df96a981665"
/>

- AI generated alert summary generated by button (Generate or
Regenerate). Stored in a new data stream
(`.kibana-elastic-ai-assistant-alert-summary-*`)
<img width="595" alt="Screenshot 2025-04-11 at 12 15 55 PM"
src="https://github.com/user-attachments/assets/ac835db2-2cbb-4a59-9e71-f1a9616a777f"
/>
- Anonymization toggle for the alert summary is located in the flyout
gear settings menu
<img width="270" alt="Screenshot 2025-04-11 at 12 32 45 PM"
src="https://github.com/user-attachments/assets/952936b9-571b-48e5-bd57-ecfd33855df3"
/>
- Highlighted fields
<img width="600" alt="Screenshot 2025-04-11 at 12 15 52 PM"
src="https://github.com/user-attachments/assets/3fccfab2-3e8b-4edc-adaf-3f320d9a5d20"
/>
- Attack discovery `MiniAttackChain` (currently hardcoded to a
preconfigured connector, waiting for further work from @andrew-goldstein
to hook up to actual alert related AD)
<img width="597" alt="Screenshot 2025-04-11 at 12 15 36 PM"
src="https://github.com/user-attachments/assets/d181f68d-5b77-4df4-a316-54e84d655a4c"
/>
- Conversations dropdown that show any conversations this alert is
referenced
<img width="601" alt="Screenshot 2025-04-11 at 12 18 03 PM"
src="https://github.com/user-attachments/assets/71d533d3-99b4-49c4-b336-05152fd64ed4"
/>
- Suggested prompts that create a new conversation with the alert as
context (_copy pending_)
<img width="594" alt="Screenshot 2025-04-11 at 12 18 09 PM"
src="https://github.com/user-attachments/assets/bca58f5a-f05c-4cdf-a466-0926c99e0ad6"
/>
- The connector used in the alert summary generation is selected in
Stack Management > Advanced Settings > Security Solution > Default AI
Connector (_copy pending_)
<img width="1163" alt="Screenshot 2025-04-11 at 12 34 15 PM"
src="https://github.com/user-attachments/assets/d2128497-22e4-4c14-b08c-991dc8287391"
/>

This PR adds 2 new prompts under a new `promptGroupId.aiForSoc`:
    - `promptDictionary.alertSummarySystemPrompt`
    - `promptDictionary.alertSummary`
In order to access these prompts in the proper spots, the new find alert
summary route returns the "user" prompt
(`promptDictionary.alertSummary`). In order to get the system prompt in
place, we pass a `promptIds` object to the
`POST_ACTIONS_CONNECTOR_EXECUTE` which is appended to the main system
prompt

This needs to be ran in Serverless:
- `yarn es serverless --projectType security`
- `yarn serverless-security --no-base-path`

You also need to enable the AI for SOC tier, by adding the following to
your `serverless.security.dev.yml` file:
```
xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]
```

Use one of these Serverless users:
- `platform_engineer`
- `endpoint_operations_analyst`
- `endpoint_policy_manager`
- `admin`
- `system_indices_superuser`

Then:
- generate data: `yarn test:generate:serverless-dev`
- create 4 catch all rules, each with a name of a AI for SOC integration
(`google_secops`, `microsoft_sentinel`,, `sentinel_one` and
`crowdstrike`) => to do that you'll need to temporary comment the
`serverless.security.dev.yaml` config changes as the rules page is not
accessible in AI for SOC.
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_fetch_integrations.ts#L73)
to `installedPackages: availablePackages` to force having some packages
installed
- change [this
line](https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_integrations.ts#L63)
to `r.name === p.name` to make sure there will be matches between
integrations and rules

With this alerts data, you should be able to test each section of the
flyout _except_ the attack discovery widget, instructions for that are
below.

As I am waiting for updates from Andrew, currently the attack discovery
widget looks up attack discoveries from a particular preconfigured
connector. In order to test:
1. Add preconfigured connector to your `kibana.dev.yml`:
https://p.elstc.co/paste/J2qmGMeQ#GKSPhlggX4F93aUSKJsKpsqtCcyTepCkfJOEVxlZyfB
2. Generate attack discovery with this connector
3. Open the new flyout, you will see the attack discovery widget

These are all noted in the code
1. Attack discovery widget is hardcoded to the preconfigured connector
id. The widget should instead look up discoveries by alert ID, pending
work from @andrew-goldstein
2. Update copy for suggested prompts
3. Update copy for ai connector UI setting
4. Update AI connector UI setting to default to Elastic Managed LLM once
it is fully available in serverless

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: PhilippeOberti <philippe.oberti@elastic.co>
Co-authored-by: Angela Chuang <yi-chun.chuang@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants