Skip to content

[8.19] [Response Ops][Alerting] Cannot read properties of undefined (reading 'getActiveCount') (#221799)#224881

Merged
doakalexi merged 1 commit intoelastic:8.19from
doakalexi:backport/8.19/pr-221799
Jun 23, 2025
Merged

[8.19] [Response Ops][Alerting] Cannot read properties of undefined (reading 'getActiveCount') (#221799)#224881
doakalexi merged 1 commit intoelastic:8.19from
doakalexi:backport/8.19/pr-221799

Conversation

@doakalexi
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

… 'getActiveCount') (elastic#221799)

Resolves elastic#208740

## Summary

This error message comes from the code where we drop the oldest
recovered alerts from being tracked in the task state when there are
more than 1000 (or alert limit) recovered alerts. The flapping refactor
fixed this specific error, but I noticed that the alert documents
weren't being updated before the alerts were dropped. This PR just moves
this logic to the function that gets all the alerts to serialize in the
task state, which happens after the alert documents are updated.

### Checklist

Check the PR satisfies following conditions.

- [ ] [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

### To verify
1. Set `xpack.alerting.rules.run.alerts.max: 3` in kibana.yml
2. Start kibana and create a rule that will generate 3 alerts
3. Stop kibana and set the max alert limit to 2 in kibana.yml
4. Start kibana and update the conditions to recover the alerts. Because
there are 3 alerts recovering and we can only track 2, one alert will be
dropped from the task state.
5. Verify that all the alerts are marked as recovered. Let the rule run
to verify that one of the alert's alert document is no longer updated.

(cherry picked from commit fff8ae9)
@doakalexi doakalexi requested a review from kibanamachine as a code owner June 23, 2025 14:18
@doakalexi doakalexi added the backport This PR is a backport of another PR label Jun 23, 2025
@doakalexi doakalexi enabled auto-merge (squash) June 23, 2025 14:18
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #38 / APM API tests service_maps/service_maps.spec.ts trial apm_8.0.0 Service Map with data /internal/apm/service-map with data with ML data with the default apm user returns the correct anomaly stats

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack-platform 342 343 +1

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack-platform 347 348 +1

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.

LGTM

@doakalexi doakalexi merged commit f218c09 into elastic:8.19 Jun 23, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants