-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Prevent duplicate notifications about the same anomaly result #91485
[ML] Prevent duplicate notifications about the same anomaly result #91485
Conversation
Pinging @elastic/ml-ui (:ml) |
Code LGTM aside from Pete's comment. Will test when PR is updated 👌 |
} else if (source.result_type === ANOMALY_RESULT_TYPE.RECORD) { | ||
const fieldName = getEntityFieldName(source); | ||
const fieldValue = getEntityFieldValue(source); | ||
alertInstanceKey += `_${source.detector_index}_${source.function}_${fieldName}_${fieldValue}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source.detector_index
is undefined
in the key my test generated. Is this available in the source
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to include it into the source, fixed in 61764c5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested latest edits and LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⚡
💚 Build SucceededMetrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: |
…lastic#91485) * [ML] check kibana even logs for existing alert instance * [ML] create alert instance key, add check for alert id * [ML] use anomaly_utils, check interval gap * [ML] add detector index * [ML] fix unit test * [ML] include detector_index into source
…91485) (#91720) * [ML] check kibana even logs for existing alert instance * [ML] create alert instance key, add check for alert id * [ML] use anomaly_utils, check interval gap * [ML] add detector index * [ML] fix unit test * [ML] include detector_index into source Co-authored-by: Dima Arnautov <[email protected]>
Summary
Related issue #88940.
The alerting framework allows configuring when to get notified. By default, it's "Only on status change", which means that in the case of the ML Anomaly detection alert schedules
Anomaly score matched the condition
action on each execution multiple times in a row, the user will be notified only on the first status change, so receiving duplicates won't be an issue.But setting it to "Every time alert is active" might result in multiple notifications for the same anomaly, depending on the check interval and the result bucket span. This PR adds a check to the ML alert executor for the existing alert instance with
anomaly_score_match
action group in.kibana-event-log-*
index that helps to avoid it.The alert instance key generated to check for duplicates is of the form
Buckets alerts:
jobId_highestRecordTimestamp
Influencer alerts:
jobId_highestRecordTimestamp_influencerFieldName_influencerFieldValue
Record alerts:
jobId_highestRecordTimestamp_detectorIndex_function_entityFieldName_entityFieldValue
e.g. for a record alert instance:
ecommerce_high_sum_total_sales_1613584800000_0_high_sum_customer_full_name.keyword_Rabbia Al Powell
Also, another scenario is possible when the check interval is significantly bigger than the result bucket span we look back during the alert condition execution. In that case, we risk missing the anomaly, hence using
previousStartedAt
time from the previous execution helps to detect the check gap and use this interval as a time range for querying anomalies.How to test
You should get notified based on the selected action only once for a particular anomaly result.
Checklist