-
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] AIOps Log Rate Analysis: improves explanation of log rate spike/dip #186342
Changes from 3 commits
5dac06b
ee5e116
383fc67
8f0a4ee
ff861eb
2686407
37471c4
31ac8ab
51abcd4
d59e594
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 |
---|---|---|
|
@@ -186,7 +186,11 @@ export const LogRateAnalysisResults: FC<LogRateAnalysisResultsProps> = ({ | |
); | ||
const [shouldStart, setShouldStart] = useState(false); | ||
const [toggleIdSelected, setToggleIdSelected] = useState(resultsGroupedOffId); | ||
const [skippedColumns, setSkippedColumns] = useState<ColumnNames[]>(['p-value']); | ||
const [skippedColumns, setSkippedColumns] = useState<ColumnNames[]>([ | ||
'p-value', | ||
'Baseline rate', | ||
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. @alvarezmelissa87 @walterra what do you think about showing the Baseline and Deviation rate columns by default, and hiding the Doc count? I like to see these columns in combination with the 'Log rate change' column. Although in the grouped view, Doc count makes sense as the new columns don't have values. 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. 🤔 I think that could work but we'd need all 3 showing up since the groups table and expanded row hare the same column controls. Might need to think about it a bit more if we want to make them independent. 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. I'm happy to leave it as it is, with baseline and deviation rate hidden by default. The more I think about it, the less I like the idea of adding two extra numeric columns into the table in the default view. |
||
'Deviation rate', | ||
]); | ||
|
||
const onGroupResultsToggle = (optionId: string) => { | ||
setToggleIdSelected(optionId); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { LOG_RATE_ANALYSIS_TYPE } from '@kbn/aiops-log-rate-analysis'; | ||
|
||
export function getLogRateChange( | ||
analysisType: typeof LOG_RATE_ANALYSIS_TYPE[keyof typeof LOG_RATE_ANALYSIS_TYPE], | ||
baselineBucketRate: number, | ||
deviationBucketRate: number | ||
) { | ||
const logRateChange = | ||
baselineBucketRate > 0 | ||
? analysisType === LOG_RATE_ANALYSIS_TYPE.SPIKE | ||
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. Our style guide recommends not doing nested ternaries. I'd suggest just using if/else in this function and return early if something matches. 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. Updated in ff861eb |
||
? `${Math.round((deviationBucketRate / baselineBucketRate) * 100) / 100}x higher` | ||
: `${Math.round((baselineBucketRate / deviationBucketRate) * 100) / 100}x lower` | ||
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. Guess we also need to add i18n to those strings. 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. Can you use https://github.com/elastic/kibana/blob/main/x-pack/plugins/ml/common/util/metric_change_description.ts for these, as used for the anomalies table? That will use 'More than 100x higher' if the factor is 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. Updated to round and to add localization in ff861eb |
||
: analysisType === LOG_RATE_ANALYSIS_TYPE.SPIKE | ||
? i18n.translate( | ||
'xpack.aiops.logRateAnalysis.resultsTableGroups.logRateIncreaseLabelColumnTooltip', | ||
{ | ||
defaultMessage: '{deviationBucketRate} docs from 0 in baseline', | ||
values: { deviationBucketRate }, | ||
} | ||
) | ||
: i18n.translate( | ||
'xpack.aiops.logRateAnalysis.resultsTableGroups.logRateDecreaseLabelColumnTooltip', | ||
{ | ||
defaultMessage: '0 docs from ${baselineBucketRate} in baseline', | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
values: { baselineBucketRate }, | ||
} | ||
); | ||
|
||
return logRateChange; | ||
} | ||
|
||
export function getBaselineAndDeviationRates( | ||
baselineBuckets: number, | ||
deviationBuckets: number, | ||
docCount: number | undefined, | ||
bgCount: number | undefined | ||
) { | ||
let baselineBucketRate; | ||
let deviationBucketRate; | ||
|
||
if (bgCount !== undefined) { | ||
baselineBucketRate = Math.round(bgCount / baselineBuckets); | ||
} | ||
|
||
if (docCount !== undefined) { | ||
deviationBucketRate = Math.round(docCount / deviationBuckets); | ||
} | ||
|
||
return { baselineBucketRate, deviationBucketRate }; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,11 @@ export const LogRateAnalysisResultsTable: FC<LogRateAnalysisResultsTableProps> = | |
const selectedSignificantItem = useAppSelector( | ||
(s) => s.logRateAnalysisTableRow.selectedSignificantItem | ||
); | ||
const { | ||
analysisType, | ||
windowParameters, | ||
documentStats: { documentCountStats }, | ||
} = useAppSelector((s) => s.logRateAnalysis); | ||
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. Since |
||
|
||
const dispatch = useAppDispatch(); | ||
|
||
|
@@ -97,6 +102,9 @@ export const LogRateAnalysisResultsTable: FC<LogRateAnalysisResultsTableProps> = | |
|
||
const columns = useColumns( | ||
LOG_RATE_ANALYSIS_RESULTS_TABLE_TYPE.SIGNIFICANT_ITEMS, | ||
analysisType, | ||
windowParameters, | ||
documentCountStats?.interval ?? 0, | ||
skippedColumns, | ||
searchQuery, | ||
barColorOverride, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,11 @@ export const LogRateAnalysisResultsGroupsTable: FC<LogRateAnalysisResultsTablePr | |
|
||
const pinnedGroup = useAppSelector((s) => s.logRateAnalysisTableRow.pinnedGroup); | ||
const selectedGroup = useAppSelector((s) => s.logRateAnalysisTableRow.selectedGroup); | ||
const { | ||
analysisType, | ||
windowParameters, | ||
documentStats: { documentCountStats }, | ||
} = useAppSelector((s) => s.logRateAnalysis); | ||
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. Since 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. Good catch - moved in ff861eb |
||
const dispatch = useAppDispatch(); | ||
const isMounted = useMountedState(); | ||
|
||
|
@@ -149,6 +154,7 @@ export const LogRateAnalysisResultsGroupsTable: FC<LogRateAnalysisResultsTablePr | |
{ | ||
'data-test-subj': 'aiopsLogRateAnalysisResultsGroupsTableColumnGroup', | ||
field: 'group', | ||
width: skippedColumns.length < 3 ? '34%' : '50%', | ||
name: ( | ||
<> | ||
<FormattedMessage | ||
|
@@ -238,6 +244,9 @@ export const LogRateAnalysisResultsGroupsTable: FC<LogRateAnalysisResultsTablePr | |
|
||
const columns = useColumns( | ||
LOG_RATE_ANALYSIS_RESULTS_TABLE_TYPE.GROUPS, | ||
analysisType, | ||
windowParameters, | ||
documentCountStats?.interval ?? 0, | ||
skippedColumns, | ||
searchQuery, | ||
barColorOverride, | ||
|
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.
Not related to the changes in this PR, but I think it would be a nice enhancement to persist the user's choice of selected columns to e.g. local storage. I found myself adding in Baseline and Deviation rates for display every time I reran an analysis.
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.
Added as an item to #181111.