Skip to content

Conversation

@kfirpeled
Copy link
Contributor

@kfirpeled kfirpeled commented Jun 22, 2025

Summary

Closes #221037 , shows alerts on the graph by querying both the logs and the alerts indices

  • Graph API - new optional indexPatterns parameters to switch data views (not in use in the UI atm). Defaults to .alerts-security.alerts-<spaceId>, logs-*
  • Visualize loaded alerts that are identified with alerts in graph preview and graph investigation

Depends on #224483
actor and target are not part of ECS yet. And to ease our development process we wish to push forward with this feature in mind.
This feature supports both cases when alert's index mappings contains definition for actor and target, and also when its not.

In this PR, we add mappings of actor and target to the es_archive of the alerts. This way we are able to test the functionality of this feature instead of being blocked by #224483.

Video 🎥
Screen.Recording.2025-06-29.at.19.42.23.mov
Screenshots 📸

Before (ignore label alignments - screenshot is from a local environment)

Screenshot 2025-06-29 at 19 33 00

After (another event is identified with alert - marking it as such and expands the alert details)

Screenshot 2025-06-29 at 19 32 30

Before network page - preview

Screenshot 2025-06-29 at 19 40 59

After network page - preview identifies if event contains alert

Screenshot 2025-06-29 at 19 40 29

How to test locally

  1. Edit kibana.dev.yml and add:
uiSettings.overrides.securitySolution:enableGraphVisualization: true
  1. Start elasticsearch and kibana locally
  2. To add mock data run the following:
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/logs_gcp_audit \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601

node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/security_alerts_modified_mappings \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601
  1. Open Alerts page in kibana. Update the date-picker to include data from a year ago. Then check one of the alerts details opening the right-side flyout and find the "Graph preview" section in it.
  2. Expand graph to show related alerts
  3. Enable Asset Inventory in the Inventory page (if you don't see the page enable the feature flag in the advanced settings)
  4. Add entities mock data
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_api/es_archives/entity_store \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601
  1. Open Alerts page in kibana. Check that the graph shows the admin entity with it's label

Checklist

@kfirpeled kfirpeled added backport:skip This PR does not require backporting Team:Cloud Security Cloud Security team related labels Jun 22, 2025
@kfirpeled kfirpeled linked an issue Jun 22, 2025 that may be closed by this pull request
3 tasks
@kfirpeled kfirpeled added the release_note:skip Skip the PR/issue when compiling release notes label Jun 29, 2025
@kfirpeled

This comment was marked as off-topic.

@kfirpeled

This comment was marked as off-topic.

@kfirpeled

This comment was marked as off-topic.

@kfirpeled

This comment was marked as off-topic.

@kfirpeled

This comment was marked as off-topic.

@kfirpeled kfirpeled marked this pull request as ready for review August 8, 2025 10:47
@kfirpeled kfirpeled requested review from a team as code owners August 8, 2025 10:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#9067

[✅] x-pack/solutions/security/test/cloud_security_posture_api/config.ts: 25/25 tests passed.
[❌] x-pack/solutions/security/test/cloud_security_posture_functional/config.ts: 0/25 tests passed.
[❌] x-pack/solutions/security/test/api_integration/apis/cloud_security_posture/config.ts: 24/25 tests passed.
[✅] x-pack/test_serverless/api_integration/test_suites/security/config.ts: 25/25 tests passed.

see run history

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#9069

[✅] x-pack/solutions/security/test/cloud_security_posture_functional/config.ts: 25/25 tests passed.
[✅] x-pack/solutions/security/test/cloud_security_posture_api/config.ts: 25/25 tests passed.

see run history

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 8, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: b5d2fff
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-224783-b5d2fff842f8

Metrics [docs]

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/cloud-security-posture-graph 20 21 +1

Async chunks

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

id before after diff
securitySolution 10.4MB 10.4MB +504.0B
Unknown metric groups

API count

id before after diff
@kbn/cloud-security-posture-graph 32 34 +2

History


// Single alert contains both event's document data and alert's document data.
if (node.documentsData.find((doc) => doc.type === 'alert') && node.documentsData.length < 2) {
if (node.documentsData.find((doc) => doc.type === 'alert') && node.documentsData.length <= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@kfirpeled why did you change it to <=2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in a single alert use case, you can have a correlated event that the alert was triggered upon. So eventually you will have 2 documents data

}

// For single-alert we might have both event and alert documents. We prefer to return the alert document if it exists.
const documentData =
Copy link
Contributor

Choose a reason for hiding this comment

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

so we are going to store in the documentsData array the event itself which we get from the log-* and also the alert we found in the alerts-* index?
What is the id of the node going to be? the event id we constructed a(something)-b(something1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so we are going to store in the documentsData array the event itself which we get from the log-* and also the alert we found in the alerts-* index?

correct

What is the id of the node going to be? the event id we constructed a(something)-b(something1)?

correct, that wasn't changed as part of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-08-10 at 15 37 37

"ignore_malformed": false,
"type": "date"
},
"actor": {
Copy link
Contributor

@alexreal1314 alexreal1314 Aug 10, 2025

Choose a reason for hiding this comment

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

@kfirpeled is this what we expect to be added to ecs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no
while a decision wasn't made yet for where these fields gonna be in ECS. We know that actor and target won't be approved to be top level fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so actor and target are currently temporary and part of a technical preview fields. Sadly it broke the ECS guidelines and once we will revert it, it will cause a breaking chnage

@kfirpeled kfirpeled merged commit 70814dd into elastic:main Aug 10, 2025
12 checks passed
@kfirpeled kfirpeled deleted the cspm/related-alert-support branch August 10, 2025 13:21
Copy link
Contributor

@albertoblaz albertoblaz left a comment

Choose a reason for hiding this comment

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

👏

await networkEventsPage.flyout.assertPreviewPanelIsOpen('event');
});

it('show related alerts', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
it('show related alerts', async () => {
it('show related events', async () => {

NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
…c#224783)

## Summary

Closes elastic#221037 , shows alerts on the graph by querying both the logs and
the alerts indices

- [x] Graph API - new optional `indexPatterns` parameters to switch data
views (not in use in the UI atm). Defaults to
`.alerts-security.alerts-<spaceId>, logs-*`
- [x] Visualize loaded alerts that are identified with alerts in graph
preview and graph investigation

~Depends on elastic#224483
`actor` and `target` are not part of ECS yet. And to ease our
development process we wish to push forward with this feature in mind.
This feature supports both cases when alert's index mappings contains
definition for `actor` and `target`, and also when its not.

In this PR, we add mappings of `actor` and `target` to the es_archive of
the alerts. This way we are able to test the functionality of this
feature instead of being blocked by
elastic#224483.


<details>
<summary>Video 🎥  </summary>


https://github.com/user-attachments/assets/bcc86214-6e88-46f3-a990-300bbdc28125

</details>


<details>
<summary>Screenshots 📸 </summary>

**Before (ignore label alignments - screenshot is from a local
environment)**

![Screenshot 2025-06-29 at 19 33
00](https://github.com/user-attachments/assets/39b014ce-6b70-44cc-a486-906d39c205fe)


**After (another event is identified with alert - marking it as such and
expands the _alert_ details)**

![Screenshot 2025-06-29 at 19 32
30](https://github.com/user-attachments/assets/824d1d6f-9c17-4c4a-a8a7-18e65b89dbb2)

**Before network page - preview**

![Screenshot 2025-06-29 at 19 40
59](https://github.com/user-attachments/assets/50716acc-b2bd-4d42-93e0-eb31cfa6fe9c)

**After network page - preview identifies if event contains alert**

![Screenshot 2025-06-29 at 19 40
29](https://github.com/user-attachments/assets/531cec9f-2fb3-4a90-9cc1-1a73684f3612)


</details>

### How to test locally

1. Edit `kibana.dev.yml` and add:

```yml
uiSettings.overrides.securitySolution:enableGraphVisualization: true
```

2. Start elasticsearch and kibana locally
3. To add mock data run the following:

```bash
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/logs_gcp_audit \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601

node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/security_alerts_modified_mappings \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601

```

3. Open `Alerts` page in kibana. Update the date-picker to include data
from a year ago. Then check one of the alerts details opening the
right-side flyout and find the "Graph preview" section in it.
4. Expand graph to show related alerts
5. Enable Asset Inventory in the `Inventory` page (if you don't see the
page enable the feature flag in the advanced settings)
6. Add entities mock data

```
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_api/es_archives/entity_store \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601
```
7. Open `Alerts` page in kibana. Check that the graph shows the admin
entity with it's label

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
qn895 pushed a commit to qn895/kibana that referenced this pull request Aug 26, 2025
…c#224783)

## Summary

Closes elastic#221037 , shows alerts on the graph by querying both the logs and
the alerts indices

- [x] Graph API - new optional `indexPatterns` parameters to switch data
views (not in use in the UI atm). Defaults to
`.alerts-security.alerts-<spaceId>, logs-*`
- [x] Visualize loaded alerts that are identified with alerts in graph
preview and graph investigation

~Depends on elastic#224483
`actor` and `target` are not part of ECS yet. And to ease our
development process we wish to push forward with this feature in mind.
This feature supports both cases when alert's index mappings contains
definition for `actor` and `target`, and also when its not.

In this PR, we add mappings of `actor` and `target` to the es_archive of
the alerts. This way we are able to test the functionality of this
feature instead of being blocked by
elastic#224483.


<details>
<summary>Video 🎥  </summary>


https://github.com/user-attachments/assets/bcc86214-6e88-46f3-a990-300bbdc28125

</details>


<details>
<summary>Screenshots 📸 </summary>

**Before (ignore label alignments - screenshot is from a local
environment)**

![Screenshot 2025-06-29 at 19 33
00](https://github.com/user-attachments/assets/39b014ce-6b70-44cc-a486-906d39c205fe)


**After (another event is identified with alert - marking it as such and
expands the _alert_ details)**

![Screenshot 2025-06-29 at 19 32
30](https://github.com/user-attachments/assets/824d1d6f-9c17-4c4a-a8a7-18e65b89dbb2)

**Before network page - preview**

![Screenshot 2025-06-29 at 19 40
59](https://github.com/user-attachments/assets/50716acc-b2bd-4d42-93e0-eb31cfa6fe9c)

**After network page - preview identifies if event contains alert**

![Screenshot 2025-06-29 at 19 40
29](https://github.com/user-attachments/assets/531cec9f-2fb3-4a90-9cc1-1a73684f3612)


</details>

### How to test locally

1. Edit `kibana.dev.yml` and add:

```yml
uiSettings.overrides.securitySolution:enableGraphVisualization: true
```

2. Start elasticsearch and kibana locally
3. To add mock data run the following:

```bash
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/logs_gcp_audit \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601

node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_functional/es_archives/security_alerts_modified_mappings \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601

```

3. Open `Alerts` page in kibana. Update the date-picker to include data
from a year ago. Then check one of the alerts details opening the
right-side flyout and find the "Graph preview" section in it.
4. Expand graph to show related alerts
5. Enable Asset Inventory in the `Inventory` page (if you don't see the
page enable the feature flag in the advanced settings)
6. Add entities mock data

```
node scripts/es_archiver load x-pack/solutions/security/test/cloud_security_posture_api/es_archives/entity_store \
 --es-url http://elastic:changeme@localhost:9200 \
 --kibana-url http://elastic:changeme@localhost:5601
```
7. Open `Alerts` page in kibana. Check that the graph shows the admin
entity with it's label

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
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 ci:build-serverless-image release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add related alerts support

6 participants