Skip to content

[APM] Add kibana.alert.grouping to latency threshold alerts#254904

Merged
fkanout merged 4 commits intoelastic:mainfrom
fkanout:224898-grouping-field-apm-latency-threshold
Mar 25, 2026
Merged

[APM] Add kibana.alert.grouping to latency threshold alerts#254904
fkanout merged 4 commits intoelastic:mainfrom
fkanout:224898-grouping-field-apm-latency-threshold

Conversation

@fkanout
Copy link
Copy Markdown
Contributor

@fkanout fkanout commented Feb 25, 2026

Summary

Fixes #224898
Implements kibana.alert.grouping for the APM Latency threshold rule (apm.transaction_duration) in line with the Observability grouping initiative.

What changed

  • Added kibana.alert.grouping to active alert payloads in the transaction duration executor.
  • Updated recovered alert context to prefer kibana.alert.grouping from the recovered alert document, with a backward-compatible fallback to reconstructed grouping for older alerts.
  • Updated latency rule unit tests to validate payload/context behavior.
  • Updated deployment-agnostic APM API integration tests to assert kibana.alert.grouping is indexed with the expected nested structure.
Screenshot 2026-02-25 at 12 57 53

Why

This ensures grouping is first-class in alert documents for filtering/searching and keeps recovered context.grouping aligned with the alert document source of truth.

Test plan

  • yarn test:jest x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.test.ts
  • yarn test:ftr --config x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.apm.stateful.config.ts --grep "transaction duration alert"

Validation results

  • Unit tests: PASS (7/7)
  • Deployment-agnostic stateful APM suite (filtered to transaction duration alert): PASS (22 passing, exit code 0)

Notes

  • No saved object migration is required.
  • Shared APM mapping support for kibana.alert.grouping.* is additive.

@fkanout fkanout self-assigned this Feb 25, 2026
@fkanout fkanout added the release_note:skip Skip the PR/issue when compiling release notes label Feb 25, 2026
@fkanout fkanout requested a review from a team as a code owner February 25, 2026 12:04
@fkanout fkanout added Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. backport:version Backport to applied version labels v9.2.0 v9.3.0 v9.4.0 labels Feb 25, 2026
@botelastic botelastic bot added the Team:obs-presentation Focus: APM UI, Infra UI, Hosts UI, Universal Profiling, Obs Overview and left Navigation label Feb 25, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/actionable-obs-team (Team:actionable-obs)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-presentation-team (Team:obs-presentation)

@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Feb 25, 2026
Copy link
Copy Markdown
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

Verified locally against OTel demo data. Created an APM latency threshold rule for frontend-proxy with group-by on service.name, service.environment, transaction.type, and transaction.name. Alert fired and kibana.alert.grouping is correctly populated:

{
  "service": {
    "name": "frontend-proxy",
    "environment": "ENVIRONMENT_NOT_DEFINED"
  },
  "transaction": {
    "type": "request",
    "name": "ingress"
  }
}

LGTM.

expect(alerts[0]).property('service.environment', 'production');
expect(alerts[0]).property('transaction.type', 'request');
expect(alerts[0]).property('transaction.name', 'tx-node');
expect(alerts[0])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 👍🏻

@mgiota
Copy link
Copy Markdown
Contributor

mgiota commented Mar 4, 2026

@fkanout I was checking a similar ticket I worked on in the past for SLO burn rate rule. I can see I had to add a dynamic template there. Here's the change I did in a draft PR a while ago. I would expect we need to do something similar to the APM rule types. I would ask @benakansara to weigh in here.

@mgiota mgiota self-requested a review March 4, 2026 07:17
@mgiota
Copy link
Copy Markdown
Contributor

mgiota commented Mar 4, 2026

I haven't test it locally. Can you share the rule configuration you used?

@benakansara
Copy link
Copy Markdown
Contributor

@fkanout I was checking a similar ticket I worked on in the past for SLO burn rate rule. I can see I had to add a dynamic template there. Here's the change I did in a draft PR a while ago. I would expect we need to do something similar to the APM rule types. I would ask @benakansara to weigh in here.

yes, we need to add dynamic template. Without it, the mapping can be incorrect affecting query results, auto complete, etc.

Current mapping without dynamic template:

 "service": {
    "properties": {
      "environment": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  },

@fkanout fkanout requested a review from a team as a code owner March 5, 2026 11:17
@fkanout
Copy link
Copy Markdown
Contributor Author

fkanout commented Mar 5, 2026

@benakansara @mgiota, thanks for the review and the heads up! Updated 4ad1d81

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #4 / Mappings editor: date range datatype should append custom format to default formats

Metrics [docs]

✅ unchanged

History

cc @fkanout

const groupByActionVariables = getGroupByActionVariables(groupByFields);
const groupingObject = unflattenObject(groupByFields);
const groupingObjectFromRecoveredAlert =
alertHits?.[ALERT_GROUPING] ?? unflattenObject(groupByFields);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was cross-referencing infra and slo and they don't use a fallback there alertHits?.[ALERT_GROUPING]

@fkanout I guess fallback doesn't hurt here. That makes me wonder if we need to add it to the other rule types? I am trying to understand in what case the alert grouping won't be in the document.

Otherwise looks good to me. @benakansara can I hear your thoughts as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we don't need the fallback here.

Copy link
Copy Markdown
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.

Code review only:

  • kibana.alert.grouping field is added to the apm rule types,
  • dynamic template changes LGTM,
  • the context.grouping for recovered alerts use the value from the alert document instead of alert state

Copy link
Copy Markdown
Contributor

@pmuellr pmuellr 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

@fkanout fkanout force-pushed the 224898-grouping-field-apm-latency-threshold branch from 20095f4 to 55b32cb Compare March 25, 2026 11:43
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Mar 25, 2026

Approvability

Verdict: Needs human review

This PR adds a new field to alert documents, constituting a feature addition with runtime behavior changes. The author doesn't own any of the modified files (all owned by @elastic/obs-presentation-team), and there's an unresolved design question about consistency with other rule types.

You can customize Macroscope's approvability policy. Learn more.

@fkanout fkanout merged commit a4aa1e4 into elastic:main Mar 25, 2026
20 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.2, 9.3

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.2 Backport failed because of merge conflicts
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 254904

Questions ?

Please refer to the Backport tool documentation

jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Mar 26, 2026
…254904)

## Summary
Fixes elastic#224898
Implements `kibana.alert.grouping` for the APM Latency threshold rule
(`apm.transaction_duration`) in line with the Observability grouping
initiative.

### What changed

- Added `kibana.alert.grouping` to active alert payloads in the
transaction duration executor.
- Updated recovered alert context to prefer `kibana.alert.grouping` from
the recovered alert document, with a backward-compatible fallback to
reconstructed grouping for older alerts.
- Updated latency rule unit tests to validate payload/context behavior.
- Updated deployment-agnostic APM API integration tests to assert
`kibana.alert.grouping` is indexed with the expected nested structure.
<img width="1550" height="1504" alt="Screenshot 2026-02-25 at 12 57 53"
src="https://github.com/user-attachments/assets/d7fd2fc6-788b-4d4a-8c02-6b3a25d1d635"
/>

## Why

This ensures grouping is first-class in alert documents for
filtering/searching and keeps recovered `context.grouping` aligned with
the alert document source of truth.

## Test plan

- `yarn test:jest
x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.test.ts`
- `yarn test:ftr --config
x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.apm.stateful.config.ts
--grep "transaction duration alert"`

## Validation results

- Unit tests: **PASS** (7/7)
- Deployment-agnostic stateful APM suite (filtered to transaction
duration alert): **PASS** (22 passing, exit code 0)

## Notes

- No saved object migration is required.
- Shared APM mapping support for `kibana.alert.grouping.*` is additive.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 27, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Apr 1, 2026
…254904)

## Summary
Fixes elastic#224898
Implements `kibana.alert.grouping` for the APM Latency threshold rule
(`apm.transaction_duration`) in line with the Observability grouping
initiative.

### What changed

- Added `kibana.alert.grouping` to active alert payloads in the
transaction duration executor.
- Updated recovered alert context to prefer `kibana.alert.grouping` from
the recovered alert document, with a backward-compatible fallback to
reconstructed grouping for older alerts.
- Updated latency rule unit tests to validate payload/context behavior.
- Updated deployment-agnostic APM API integration tests to assert
`kibana.alert.grouping` is indexed with the expected nested structure.
<img width="1550" height="1504" alt="Screenshot 2026-02-25 at 12 57 53"
src="https://github.com/user-attachments/assets/d7fd2fc6-788b-4d4a-8c02-6b3a25d1d635"
/>

## Why

This ensures grouping is first-class in alert documents for
filtering/searching and keeps recovered `context.grouping` aligned with
the alert document source of truth.

## Test plan

- `yarn test:jest
x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.test.ts`
- `yarn test:ftr --config
x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.apm.stateful.config.ts
--grep "transaction duration alert"`

## Validation results

- Unit tests: **PASS** (7/7)
- Deployment-agnostic stateful APM suite (filtered to transaction
duration alert): **PASS** (22 passing, exit code 0)

## Notes

- No saved object migration is required.
- Shared APM mapping support for `kibana.alert.grouping.*` is additive.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
…254904)

## Summary
Fixes elastic#224898
Implements `kibana.alert.grouping` for the APM Latency threshold rule
(`apm.transaction_duration`) in line with the Observability grouping
initiative.

### What changed

- Added `kibana.alert.grouping` to active alert payloads in the
transaction duration executor.
- Updated recovered alert context to prefer `kibana.alert.grouping` from
the recovered alert document, with a backward-compatible fallback to
reconstructed grouping for older alerts.
- Updated latency rule unit tests to validate payload/context behavior.
- Updated deployment-agnostic APM API integration tests to assert
`kibana.alert.grouping` is indexed with the expected nested structure.
<img width="1550" height="1504" alt="Screenshot 2026-02-25 at 12 57 53"
src="https://github.com/user-attachments/assets/d7fd2fc6-788b-4d4a-8c02-6b3a25d1d635"
/>

## Why

This ensures grouping is first-class in alert documents for
filtering/searching and keeps recovered `context.grouping` aligned with
the alert document source of truth.

## Test plan

- `yarn test:jest
x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.test.ts`
- `yarn test:ftr --config
x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.apm.stateful.config.ts
--grep "transaction duration alert"`

## Validation results

- Unit tests: **PASS** (7/7)
- Deployment-agnostic stateful APM suite (filtered to transaction
duration alert): **PASS** (22 passing, exit code 0)

## Notes

- No saved object migration is required.
- Shared APM mapping support for `kibana.alert.grouping.*` is additive.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

6 similar comments
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 254904 locally
cc: @fkanout

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 missing Added to PRs automatically when the are determined to be missing a backport. backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:obs-presentation Focus: APM UI, Infra UI, Hosts UI, Universal Profiling, Obs Overview and left Navigation v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[APM Latency threshold rule] Add kibana.alert.grouping field

8 participants