Skip to content

Conversation

kfirpeled
Copy link
Contributor

@kfirpeled kfirpeled commented Jun 18, 2025

Summary

resolve #221036

Adds new fields mapping: actor.entity.id, target.entity.id, related.entity of type keyword to the security's alert index.
These fields are necessary for querying the alerts index as part of the graph feature (#221037).

related.entity is currently waiting for ECS approval - elastic/ecs#2360
actor.entity.id, target.entity.id are added only to security's alerts

How this PR effects:

  • Allows the user filter by actor.entity.id, target.entity.id, related.entity
Video 🎥 **Before:**
Screen.Recording.2025-06-18.at.19.19.18.mov

After:

Screen.Recording.2025-06-18.at.19.21.51.mov

Besides the immediate effect of the ability to fetch data using these fields, this PR is a requirement to move forward with upcoming features like: #224783

Example video of upcoming use 🎥
Screen.Recording.2025-06-29.at.19.42.23.mov

How to test locally

  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 \
 --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. Filter by one of these fields

Checklist

Identify risks

  • In case the new mapping is not applied on existing documents, it means they won't be retrieved using the new fields

@kfirpeled kfirpeled added release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related backport:prev-major labels Jun 18, 2025
@kfirpeled kfirpeled marked this pull request as ready for review June 18, 2025 18:05
@kfirpeled kfirpeled requested review from a team as code owners June 18, 2025 18:05
@elasticmachine
Copy link
Contributor

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

@kfirpeled kfirpeled marked this pull request as draft June 25, 2025 12:33
@kfirpeled kfirpeled marked this pull request as ready for review June 26, 2025 15:30
@kfirpeled kfirpeled requested a review from a team as a code owner June 26, 2025 15:30
@kfirpeled kfirpeled requested a review from denar50 June 26, 2025 15:30
* 2.0.
*/

import { alertsFieldMap8190 } from '../8.19.0';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that correct to import from 8.19? or should I've imported from earlier release?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine, given that the new mappings are always based on those of the previous release.

@kfirpeled kfirpeled added backport:skip This PR does not require backporting and removed backport:prev-major labels Jun 26, 2025
@kfirpeled kfirpeled requested a review from a team as a code owner June 27, 2025 10:05
@kfirpeled kfirpeled force-pushed the cspm/alerts-mapping-update branch from f0269b4 to ffc9f2b Compare June 27, 2025 10:06
@kfirpeled kfirpeled requested review from ymao1 and removed request for a team June 27, 2025 10:07
Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

response ops changes lgtm

Copy link
Contributor

@denar50 denar50 left a comment

Choose a reason for hiding this comment

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

LGTM! I have ran the PR locally and tested that indeed I am able to filter by the added fields following the instructions provided.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

@kfirpeled kfirpeled marked this pull request as draft July 13, 2025 08:08
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

kfirpeled added a commit that referenced this pull request Aug 10, 2025
## Summary

Closes #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 #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.


<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)
@kfirpeled kfirpeled closed this Aug 10, 2025
@kfirpeled
Copy link
Contributor Author

An agreement on the fields yet to come, closing the PR for now

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 release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply new mappings to alerts index
4 participants