Skip to content

[Observability] [Alerting] Fix alert tags when source tags is a string#259729

Merged
benakansara merged 2 commits intoelastic:mainfrom
benakansara:fix/tags-as-string-issue
Mar 26, 2026
Merged

[Observability] [Alerting] Fix alert tags when source tags is a string#259729
benakansara merged 2 commits intoelastic:mainfrom
benakansara:fix/tags-as-string-issue

Conversation

@benakansara
Copy link
Copy Markdown
Contributor

@benakansara benakansara commented Mar 26, 2026

Resolves #259504

When source documents have tags as a string instead of an array, the spread syntax [...(additionalContext.tags ?? [])] iterates characters, producing per-character tags on the alert (e.g. t, e, s, t, ...). This PR normalizes tags to an array before merging with rule tags, fixing the inventory threshold, metric threshold, and custom threshold executors.

@benakansara benakansara self-assigned this Mar 26, 2026
@benakansara benakansara requested a review from a team as a code owner March 26, 2026 10:30
@benakansara benakansara added release_note:fix backport:all-open Backport to all branches that could still receive a release labels Mar 26, 2026
@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Mar 26, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Mar 26, 2026

Approvability

Verdict: Would Approve

This is a small, focused bug fix that handles an edge case where source tags come in as a string rather than an array. The fix uses .flat() to normalize input, is applied consistently across 3 files, and is well-covered by new unit tests. The author owns all changed files.

Macroscope would have approved this PR. A repo admin can enable approvability here.

Copy link
Copy Markdown
Contributor

@miguelmartin-elastic miguelmartin-elastic left a comment

Choose a reason for hiding this comment

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

lgtm!

@benakansara benakansara enabled auto-merge (squash) March 26, 2026 11:41
@benakansara benakansara merged commit cd62e65 into elastic:main Mar 26, 2026
18 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.2, 9.3

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

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ security / entity_store ] plugin / local-serverless-security_complete - Entity Store History Snapshot - history snapshot: copies latest to history index and resets behaviors on latest

Metrics [docs]

✅ unchanged

cc @benakansara

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 26, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.

(cherry picked from commit cd62e65)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 26, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.

(cherry picked from commit cd62e65)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 26, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.

(cherry picked from commit cd62e65)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.2
9.3

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

Questions ?

Please refer to the Backport tool documentation

shahargl pushed a commit to shahargl/kibana that referenced this pull request Mar 26, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.
kibanamachine added a commit that referenced this pull request Mar 26, 2026
… string (#259729) (#259767)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Observability] [Alerting] Fix alert tags when source tags is a
string (#259729)](#259729)

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

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

<!--BACKPORT [{"author":{"name":"Bena
Kansara","email":"69037875+benakansara@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-03-26T12:02:31Z","message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:all-open","v9.4.0","author:actionable-obs"],"title":"[Observability]
[Alerting] Fix alert tags when source tags is a
string","number":259729,"url":"https://github.com/elastic/kibana/pull/259729","mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/259729","number":259729,"mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}}]}]
BACKPORT-->

Co-authored-by: Bena Kansara <69037875+benakansara@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Mar 26, 2026
… string (#259729) (#259768)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Observability] [Alerting] Fix alert tags when source tags is a
string (#259729)](#259729)

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

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

<!--BACKPORT [{"author":{"name":"Bena
Kansara","email":"69037875+benakansara@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-03-26T12:02:31Z","message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:all-open","v9.4.0","author:actionable-obs"],"title":"[Observability]
[Alerting] Fix alert tags when source tags is a
string","number":259729,"url":"https://github.com/elastic/kibana/pull/259729","mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/259729","number":259729,"mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}}]}]
BACKPORT-->

Co-authored-by: Bena Kansara <69037875+benakansara@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Mar 26, 2026
…a string (#259729) (#259766)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Observability] [Alerting] Fix alert tags when source tags is a
string (#259729)](#259729)

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

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

<!--BACKPORT [{"author":{"name":"Bena
Kansara","email":"69037875+benakansara@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-03-26T12:02:31Z","message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:all-open","v9.4.0","author:actionable-obs"],"title":"[Observability]
[Alerting] Fix alert tags when source tags is a
string","number":259729,"url":"https://github.com/elastic/kibana/pull/259729","mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/259729","number":259729,"mergeCommit":{"message":"[Observability]
[Alerting] Fix alert tags when source tags is a string
(#259729)\n\nResolves
https://github.com/elastic/kibana/issues/259504\n\nWhen source documents
have tags as a string instead of an array, the\nspread syntax
[...(additionalContext.tags ?? [])] iterates characters,\nproducing
per-character tags on the alert (e.g. t, e, s, t, ...). This\nPR
normalizes tags to an array before merging with rule tags, fixing
the\ninventory threshold, metric threshold, and custom threshold
executors.","sha":"cd62e658addd633767c0c56cea66c0353bb52cec"}}]}]
BACKPORT-->

---------

Co-authored-by: Bena Kansara <69037875+benakansara@users.noreply.github.com>
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Apr 1, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
elastic#259729)

Resolves elastic#259504

When source documents have tags as a string instead of an array, the
spread syntax [...(additionalContext.tags ?? [])] iterates characters,
producing per-character tags on the alert (e.g. t, e, s, t, ...). This
PR normalizes tags to an array before merging with rule tags, fixing the
inventory threshold, metric threshold, and custom threshold executors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:all-open Backport to all branches that could still receive a release release_note:fix v8.19.14 v9.2.8 v9.3.3 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inventory / custom /metric threshold alerts: source tags stored as a string is spread into per-character tags

4 participants