[alerting] replace alert instance summary calculation of alert duration #107591
Labels
Feature:Alerting/RulesFramework
Issues related to the Alerting Rules Framework
Feature:Alerting
Team:ResponseOps
Label for the ResponseOps team (formerly the Cases and Alerting teams)
The calculation of the "alert duration", we are doing today is expensive. The relevant code is in this module:
x-pack/plugins/alerting/server/lib/alert_instance_summary_from_event_log.ts
which is called from here:kibana/x-pack/plugins/alerting/server/rules_client/rules_client.ts
Lines 453 to 463 in 946e145
Basically, in previous releases, we didn't have the alert duration available directly in active-instance events, so we had to calculate it by finding the closest new-instance event. The date on the new-instance event becomes the
activeStartDate
in the AlertInstanceStatus:kibana/x-pack/plugins/alerting/common/alert_instance_summary.ts
Lines 28 to 34 in 946e145
There were problems with this approach anyway, as the query getting the event log docs may not have gone far enough back to find a relevant new-instance event. But the big win will be not having to return all the event log docs, to get the alert duration, we can just get the last active-instance event, which contains the duration.
Another optimization we could make is to move the alert duration into the task manager state, shape here, since I think we already have to get the task manager state whenever we calculate the alert instance summary:
kibana/x-pack/plugins/alerting/common/alert_instance.ts
Lines 11 to 21 in 946e145
The text was updated successfully, but these errors were encountered: