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
[Uptime] Duration Anomaly Alert #71208
Conversation
x-pack/plugins/ml/server/shared_services/providers/results_service.ts
Outdated
Show resolved
Hide resolved
Pinging @elastic/uptime (Team:uptime) |
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.
Code is looking great to me, and functionality seemed to work well. I did ask for tests on one file, no real concerns otherwise. @andrewvc I'd prefer if you could also test the functionality. I didn't get quite as much time as I'd like to sit with such a large addition, but it seemed to work well.
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.
ML changes LGTM.
Note, I will probably alter these changes very soon as I want to implement a standard way for plugins to call our shared functions when a request object is not available.
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.
I notice that the "Enable Anomaly Alert" button does not change state to "Disable" without a page reload. Can we fix that?
This is a partial review to give you early feedback, more to come.
|
||
export const DurationAnomalyTranslations = { | ||
defaultActionMessage: i18n.translate('xpack.uptime.alerts.durationAnomaly.defaultActionMessage', { | ||
defaultMessage: `A {severity} level anomaly with score {severityScore} was detected at {anomalyStartTimestamp} on {monitor} response duration in Uptime at url {monitorUrl}. |
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.
Reading the output, this first sentence is very awkward (I know, I wrote the original). WDYT of the following?
defaultMessage: `A {severity} level anomaly with score {severityScore} was detected at {anomalyStartTimestamp} on {monitor} response duration in Uptime at url {monitorUrl}. | |
defaultMessage: `Abnormal ({severity} level) response time detected on {monitor}({monitorUrl} at {anomalyStartTimestamp}. Anomaly severity score is {severityScore}. |
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.
Left some additional comments. The main issue is the lack of tests at this stage, specifically functional tests. We'll need those to proceed.
@andrewvc added tests here https://github.com/elastic/kibana/pull/71548/files#diff-93325d7c505bcd0cbcc2c5d74267a00b |
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.
ML changes 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
}); | ||
|
||
it('can delete existing job', async () => { | ||
if (await uptime.ml.alreadyHasJob()) { |
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.
This seems really weird, it's a test that may or may not do anything. This should just go in the before hook unless I'm missing something.
}); | ||
|
||
it('can create job successfully', async () => { | ||
await uptime.ml.createMLJob(); |
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.
It looks like this tests both anomaly alerts and enabling ML. We should just move the existing ML tests here to prevent duplication after FF .
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
History
To update your PR or re-run it, just comment with: |
Summary
Fixes: #69276
User can enable/disable anomaly alert for uptime response duration anomaly detection job.
Once user enable anomaly detection job, alert creation flyout will pop. User can define criteria and connector in flyout.
Alternatively, user can create alert by clicking popover in duration chart by clicking enable anomaly alert.
If job is already there, it will says "Disable anomaly alert" hence user can delete the alert.
Testing:
To test anomalies alerts, you can change in file
xpack/plugins/uptime/server/lib/alerts/duration_anomaly.ts
line 53 from
moment(lastCheckedAt).valueOf(),
to
moment(lastCheckedAt).subtract(15, 'days').valueOf(),
and connect local kibana to cluster https://dev-next-oblt.elastic.dev/ there we have monitors like android-homepage which have data to get anomalies, specify alerts and actions, and you will get messages.