Skip to content

[Custom threshold] Save group by information with dynamic mapping#219826

Merged
maryam-saeidi merged 24 commits intoelastic:mainfrom
maryam-saeidi:183248-dynamically-mapped-groups
May 24, 2025
Merged

[Custom threshold] Save group by information with dynamic mapping#219826
maryam-saeidi merged 24 commits intoelastic:mainfrom
maryam-saeidi:183248-dynamically-mapped-groups

Conversation

@maryam-saeidi
Copy link
Member

@maryam-saeidi maryam-saeidi commented May 1, 2025

Relaetd to #183248
Auto-increasing mapping limit PR: #216719

Summary

In this PR, we are saving dynamically mapped group by information for the custom threshold rule. This consists of two parts:

  1. Adding a dynamic field
// kibana.alert.grouping
[ALERT_GROUPING]: {
    type: 'object',
    dynamic: true,
    array: false,
    required: false,
  },
  1. Adding a dynamic template
dynamicTemplates: [
      {
        strings_as_keywords: {
          path_match: 'kibana.alert.grouping.*',
          match_mapping_type: 'string',
          mapping: {
            type: 'keyword',
            ignore_above: 1024,
          },
        },
      },
    ],

The result of adding these mappings can be seen below:

Alert Mapping
image image

If the number of mapping limit is exceeded, the fields that are not mapped are going to be added to the _ignored field, but the value is available in the doc.

@maryam-saeidi maryam-saeidi added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels May 1, 2025
@maryam-saeidi maryam-saeidi self-assigned this May 1, 2025
@prodsecmachine
Copy link
Collaborator

prodsecmachine commented May 1, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@maryam-saeidi maryam-saeidi added release_note:feature Makes this part of the condensed release notes and removed release_note:skip Skip the PR/issue when compiling release notes labels May 6, 2025
@maryam-saeidi maryam-saeidi changed the title Save group by information with dynamic mapping [Custom threshold] Save group by information with dynamic mapping May 6, 2025
@maryam-saeidi maryam-saeidi added backport:version Backport to applied version labels v8.19.0 v9.1.0 and removed backport:skip This PR does not require backporting labels May 6, 2025
@maryam-saeidi maryam-saeidi marked this pull request as ready for review May 6, 2025 10:50
@maryam-saeidi maryam-saeidi requested review from a team as code owners May 6, 2025 10:50
@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label May 6, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@maryam-saeidi maryam-saeidi added the author:obs-ux-management PRs authored by the obs ux management team label May 12, 2025
@maryam-saeidi maryam-saeidi force-pushed the 183248-dynamically-mapped-groups branch from b9d16e3 to 6da4ea4 Compare May 16, 2025 15:17
@mgiota
Copy link
Contributor

mgiota commented May 19, 2025

@maryam-saeidi I read through the above mentioned issues to get the context and understand what I need to review here.

Here's a rule that I created and what I got. I created a rule with group by host.name and tags and I added test in the tags field. Is it ok that I got both kibana.alert.group and kibana.alert.grouping? Notice how the tags is saved.

Screenshot 2025-05-20 at 00 10 33 Screenshot 2025-05-20 at 00 11 03

@maryam-saeidi
Copy link
Member Author

@maryam-saeidi I read through the above mentioned issues to get the context and understand what I need to review here.

Here's a rule that I created and what I got. I created a rule with group by host.name and tags and I added test in the tags field. Is it ok that I got both kibana.alert.group and kibana.alert.grouping? Notice how the tags is saved.

@mgiota Yes, having both kibana.alert.group and kibana.alert.grouping is OK. We don't have a plan to remove kibana.alert.group as we are using it in many places, and users might rely on it, so this PR only adds kibana.alert.grouping as an addition.

Regarding tags, I will take a look to see what the issue is, but since Kevin mentioned this issue before, it seems unrelated to this PR.

Copy link
Contributor

@mgiota mgiota left a comment

Choose a reason for hiding this comment

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

LGTM!

@maryam-saeidi
Copy link
Member Author

@mgiota For the tag issue, I checked locally and it was also happening for the ES Query rule. I've created a ticket for it: #221252

Copy link
Contributor

@ersin-erdal ersin-erdal left a comment

Choose a reason for hiding this comment

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

ResponseOps changes LGTM.
Just a note: legacyExperimentalFieldMap is used in some different places as well, such as sloBurnRateRuleType, apmRuleTypeAlertFieldMap or timelines. So this new field will be added there too.

@maryam-saeidi
Copy link
Member Author

maryam-saeidi commented May 23, 2025

ResponseOps changes LGTM. Just a note: legacyExperimentalFieldMap is used in some different places as well, such as sloBurnRateRuleType, apmRuleTypeAlertFieldMap or timelines. So this new field will be added there too.

We will add this field to other observability rules as well, so it aligns with the direction that we are going.
Thanks for your review 🙏🏻

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #74 / Security Solution - Telemetry Security Telemetry - Indices metadata task telemetry @ess indices metadata index stats events should have the expected fields

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/alerting-rule-utils 13 17 +4
@kbn/rule-data-utils 180 181 +1
total +5

Async chunks

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

id before after diff
apm 2.5MB 2.5MB +10.0B
cases 1.3MB 1.3MB +5.0B
embeddableAlertsTable 853.9KB 853.9KB +5.0B
infra 1.1MB 1.1MB +14.0B
ml 5.3MB 5.3MB +5.0B
observability 1.3MB 1.3MB +55.0B
securitySolution 9.2MB 9.2MB +5.0B
slo 923.7KB 923.7KB +5.0B
triggersActionsUi 1.4MB 1.4MB +5.0B
total +109.0B

Page load bundle

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

id before after diff
observability 93.5KB 93.5KB +30.0B
timelines 177.6KB 177.7KB +73.0B
total +103.0B
Unknown metric groups

API count

id before after diff
@kbn/alerting-rule-utils 13 17 +4
@kbn/rule-data-utils 192 193 +1
total +5

History

cc @maryam-saeidi

@maryam-saeidi maryam-saeidi merged commit 1ec3296 into elastic:main May 24, 2025
11 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15227438358

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 219826

Questions ?

Please refer to the Backport tool documentation

@maryam-saeidi
Copy link
Member Author

💚 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

maryam-saeidi added a commit that referenced this pull request May 26, 2025
…ing (#219826) (#221476)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Custom threshold] Save group by information with dynamic mapping
(#219826)](#219826)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"maryam.saeidi@elastic.co"},"sourceCommit":{"committedDate":"2025-05-24T13:17:43Z","message":"[Custom
threshold] Save group by information with dynamic mapping
(#219826)\n\nRelaetd to #183248
\nAuto-increasing mapping limit
PR:\nhttps://github.com//pull/216719\n\n## Summary\n\nIn
this PR, we are saving dynamically mapped group by information for\nthe
custom threshold rule. This consists of two parts:\n\n1. Adding a
dynamic field\n```\n// kibana.alert.grouping\n[ALERT_GROUPING]: {\n
type: 'object',\n dynamic: true,\n array: false,\n required: false,\n
},\n```\n2. Adding a dynamic template\n```\ndynamicTemplates: [\n {\n
strings_as_keywords: {\n path_match: 'kibana.alert.grouping.*',\n
match_mapping_type: 'string',\n mapping: {\n type: 'keyword',\n
ignore_above: 1024,\n },\n },\n },\n ],\n```\n\nThe result of adding
these mappings can be seen
below:\n|Alert|Mapping|\n|---|---|\n\n|![image](https://github.com/user-attachments/assets/811b547b-b270-471c-92e5-582dc09b7957)|![image](https://github.com/user-attachments/assets/00389406-109a-4302-8966-5f249e4c1512)|\n\nIf
the number of mapping limit is exceeded, the fields that are not\nmapped
are going to be added to the `_ignored` field, but the value
is\navailable in the
doc.\n\n<img\nsrc=\"https://github.com/user-attachments/assets/b84bcf03-b757-4f37-a93f-2559aefa5bcf\"\nwidth=500
/>","sha":"1ec32967f857f6e6e2b9f45f4da5751997254e4e","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0","author:obs-ux-management"],"title":"[Custom
threshold] Save group by information with dynamic
mapping","number":219826,"url":"https://github.com/elastic/kibana/pull/219826","mergeCommit":{"message":"[Custom
threshold] Save group by information with dynamic mapping
(#219826)\n\nRelaetd to #183248
\nAuto-increasing mapping limit
PR:\nhttps://github.com//pull/216719\n\n## Summary\n\nIn
this PR, we are saving dynamically mapped group by information for\nthe
custom threshold rule. This consists of two parts:\n\n1. Adding a
dynamic field\n```\n// kibana.alert.grouping\n[ALERT_GROUPING]: {\n
type: 'object',\n dynamic: true,\n array: false,\n required: false,\n
},\n```\n2. Adding a dynamic template\n```\ndynamicTemplates: [\n {\n
strings_as_keywords: {\n path_match: 'kibana.alert.grouping.*',\n
match_mapping_type: 'string',\n mapping: {\n type: 'keyword',\n
ignore_above: 1024,\n },\n },\n },\n ],\n```\n\nThe result of adding
these mappings can be seen
below:\n|Alert|Mapping|\n|---|---|\n\n|![image](https://github.com/user-attachments/assets/811b547b-b270-471c-92e5-582dc09b7957)|![image](https://github.com/user-attachments/assets/00389406-109a-4302-8966-5f249e4c1512)|\n\nIf
the number of mapping limit is exceeded, the fields that are not\nmapped
are going to be added to the `_ignored` field, but the value
is\navailable in the
doc.\n\n<img\nsrc=\"https://github.com/user-attachments/assets/b84bcf03-b757-4f37-a93f-2559aefa5bcf\"\nwidth=500
/>","sha":"1ec32967f857f6e6e2b9f45f4da5751997254e4e"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219826","number":219826,"mergeCommit":{"message":"[Custom
threshold] Save group by information with dynamic mapping
(#219826)\n\nRelaetd to #183248
\nAuto-increasing mapping limit
PR:\nhttps://github.com//pull/216719\n\n## Summary\n\nIn
this PR, we are saving dynamically mapped group by information for\nthe
custom threshold rule. This consists of two parts:\n\n1. Adding a
dynamic field\n```\n// kibana.alert.grouping\n[ALERT_GROUPING]: {\n
type: 'object',\n dynamic: true,\n array: false,\n required: false,\n
},\n```\n2. Adding a dynamic template\n```\ndynamicTemplates: [\n {\n
strings_as_keywords: {\n path_match: 'kibana.alert.grouping.*',\n
match_mapping_type: 'string',\n mapping: {\n type: 'keyword',\n
ignore_above: 1024,\n },\n },\n },\n ],\n```\n\nThe result of adding
these mappings can be seen
below:\n|Alert|Mapping|\n|---|---|\n\n|![image](https://github.com/user-attachments/assets/811b547b-b270-471c-92e5-582dc09b7957)|![image](https://github.com/user-attachments/assets/00389406-109a-4302-8966-5f249e4c1512)|\n\nIf
the number of mapping limit is exceeded, the fields that are not\nmapped
are going to be added to the `_ignored` field, but the value
is\navailable in the
doc.\n\n<img\nsrc=\"https://github.com/user-attachments/assets/b84bcf03-b757-4f37-a93f-2559aefa5bcf\"\nwidth=500
/>","sha":"1ec32967f857f6e6e2b9f45f4da5751997254e4e"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
…astic#219826)

Relaetd to elastic#183248 
Auto-increasing mapping limit PR:
elastic#216719

## Summary

In this PR, we are saving dynamically mapped group by information for
the custom threshold rule. This consists of two parts:

1. Adding a dynamic field
```
// kibana.alert.grouping
[ALERT_GROUPING]: {
    type: 'object',
    dynamic: true,
    array: false,
    required: false,
  },
```
2. Adding a dynamic template
```
dynamicTemplates: [
      {
        strings_as_keywords: {
          path_match: 'kibana.alert.grouping.*',
          match_mapping_type: 'string',
          mapping: {
            type: 'keyword',
            ignore_above: 1024,
          },
        },
      },
    ],
```

The result of adding these mappings can be seen below:
|Alert|Mapping|
|---|---|

|![image](https://github.com/user-attachments/assets/811b547b-b270-471c-92e5-582dc09b7957)|![image](https://github.com/user-attachments/assets/00389406-109a-4302-8966-5f249e4c1512)|

If the number of mapping limit is exceeded, the fields that are not
mapped are going to be added to the `_ignored` field, but the value is
available in the doc.

<img
src="https://github.com/user-attachments/assets/b84bcf03-b757-4f37-a93f-2559aefa5bcf"
width=500 />
@maryam-saeidi maryam-saeidi deleted the 183248-dynamically-mapped-groups branch June 17, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:obs-ux-management PRs authored by the obs ux management team backport:version Backport to applied version labels release_note:feature Makes this part of the condensed release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants