-
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] Explain log rate spikes: Analysis API endpoint. #135058
Changes from 14 commits
7e4abec
87ca4c8
968f4fb
7a31ff6
0bd6bfd
3a25375
82e312c
d478d0d
f3d8da9
00ad51a
d0466bb
26b0bbd
10ed875
24d1f1c
87d9d8f
9c3ad32
fd3590b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiProgress, EuiText } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React from 'react'; | ||
|
||
interface ProgressControlProps { | ||
progress: number; | ||
progressMessage: string; | ||
onRefresh: () => void; | ||
onCancel: () => void; | ||
isRunning: boolean; | ||
} | ||
|
||
export function ProgressControls({ | ||
progress, | ||
progressMessage, | ||
onRefresh, | ||
onCancel, | ||
isRunning, | ||
}: ProgressControlProps) { | ||
return ( | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiFlexGroup direction="column" gutterSize="none"> | ||
<EuiFlexItem data-test-subj="aiopProgressTitle"> | ||
<EuiText size="xs" color="subdued"> | ||
<FormattedMessage | ||
data-test-subj="aiopsProgressTitleMessage" | ||
id="xpack.aiops.progressTitle" | ||
defaultMessage="Progress: {progress}% — {progressMessage}" | ||
values={{ progress: Math.round(progress * 100), progressMessage }} | ||
/> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiProgress | ||
aria-label={i18n.translate('xpack.aiops.progressAriaLabel', { | ||
defaultMessage: 'Progress', | ||
})} | ||
value={Math.round(progress * 100)} | ||
max={100} | ||
size="m" | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
{!isRunning && ( | ||
<EuiButton size="s" onClick={onRefresh}> | ||
<FormattedMessage id="xpack.aiops.refreshButtonTitle" defaultMessage="Refresh" /> | ||
</EuiButton> | ||
)} | ||
{isRunning && ( | ||
<EuiButton size="s" onClick={onCancel}> | ||
<FormattedMessage id="xpack.aiops.cancelButtonTitle" defaultMessage="Cancel" /> | ||
</EuiButton> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/** | ||
* Time range definition for baseline and deviation to be used by spike log analysis. | ||
*/ | ||
export interface WindowParameters { | ||
baselineMin: number; | ||
baselineMax: number; | ||
deviationMin: number; | ||
deviationMax: number; | ||
} | ||
|
||
/** | ||
* Given a point in time (e.g. where a user clicks), use simple heuristics to compute: | ||
* | ||
* 1. The time window around the click to evaluate for changes | ||
* 2. The historical time window prior to the click to use as a baseline. | ||
* | ||
* The philosophy here is that charts are displayed with different granularities according to their | ||
* overall time window. We select the change point and historical time windows inline with the | ||
* overall time window. | ||
* | ||
* The algorithm for doing this is based on the typical granularities that exist in machine data. | ||
* | ||
* @param clickTime timestamp of the clicked log rate spike. | ||
* @param minTime minimum timestamp of the time window to be analysed | ||
* @param maxTime maximum timestamp of the time window to be analysed | ||
* @returns WindowParameters | ||
*/ | ||
export const getWindowParameters = ( | ||
clickTime: number, | ||
minTime: number, | ||
maxTime: number | ||
): WindowParameters => { | ||
const totalWindow = maxTime - minTime; | ||
|
||
// min deviation window | ||
const minDeviationWindow = 10 * 60 * 1000; // 10min | ||
const minBaselineWindow = 30 * 60 * 1000; // 30min | ||
const minWindowGap = 5 * 60 * 1000; // 5min | ||
|
||
// work out bounds | ||
const deviationWindow = Math.max(totalWindow / 10, minDeviationWindow); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would benefit from a comment to say why you are picking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const baselineWindow = Math.max(totalWindow / 3.5, minBaselineWindow); | ||
const windowGap = Math.max(totalWindow / 10, minWindowGap); | ||
|
||
const deviationMin = clickTime - deviationWindow / 2; | ||
const deviationMax = clickTime + deviationWindow / 2; | ||
|
||
const baselineMax = deviationMin - windowGap; | ||
const baselineMin = baselineMax - baselineWindow; | ||
|
||
return { | ||
baselineMin: Math.round(baselineMin), | ||
baselineMax: Math.round(baselineMax), | ||
deviationMin: Math.round(deviationMin), | ||
deviationMax: Math.round(deviationMax), | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const SPIKE_ANALYSIS_THRESHOLD = 0.02; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ export const PLUGIN_NAME = 'AIOps'; | |
* This is an internal hard coded feature flag so we can easily turn on/off the | ||
* "Explain log rate spikes UI" during development until the first release. | ||
*/ | ||
export const AIOPS_ENABLED = false; | ||
export const AIOPS_ENABLED = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to switch this back to false for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with Pete and we're going to leave this enabled for now. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface FieldValuePair { | ||
fieldName: string; | ||
fieldValue: string; | ||
isFallbackResult?: boolean; | ||
} | ||
|
||
export interface ChangePoint extends FieldValuePair { | ||
doc_count: number; | ||
bg_count: number; | ||
score: number; | ||
pValue: number | null; | ||
} |
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.
A bad choice of data set, but with the
event_rate
data set, the analysis stops at 20%. As discussed, it should abort and return 100%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.
Fixed in 9c3ad32.