Skip to content
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: improve explanation of log rate spike/dip #186342

Merged

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Jun 17, 2024

Summary

Related issue: #182714

This PR adds a Log rate change column to Log rate analysis results table.

The log rate change is calculated by getting the number of buckets for baseline/deviation using the timerange and interval and then comparing the average rates per bucket for baseline vs deviation.

image image

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 added release_note:enhancement :ml Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis v8.15.0 labels Jun 17, 2024
@alvarezmelissa87 alvarezmelissa87 self-assigned this Jun 17, 2024
@alvarezmelissa87 alvarezmelissa87 marked this pull request as ready for review June 18, 2024 22:10
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner June 18, 2024 22:10
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Comment on lines 19 to 20
? `${Math.round((deviationBucketRate / baselineBucketRate) * 100) / 100}x higher`
: `${Math.round((baselineBucketRate / deviationBucketRate) * 100) / 100}x lower`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we also need to add i18n to those strings.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 > 100, which is probably appropriate to use here too? Or if you can't call that same code, then use the same rules around precision so that e.g. x14.23 higher becomes x14 higher.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to round and to add localization in ff861eb

) {
const logRateChange =
baselineBucketRate > 0
? analysisType === LOG_RATE_ANALYSIS_TYPE.SPIKE
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in ff861eb

Comment on lines 86 to 90
const {
analysisType,
windowParameters,
documentStats: { documentCountStats },
} = useAppSelector((s) => s.logRateAnalysis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since useColumns is a hook, you could move this inside the hook itself so doesn't need to get passed on as arguments to useColumns.

Comment on lines 96 to 100
const {
analysisType,
windowParameters,
documentStats: { documentCountStats },
} = useAppSelector((s) => s.logRateAnalysis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since useColumns is a hook, you could move this inside the hook itself so doesn't need to get passed on as arguments to useColumns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - moved in ff861eb

sortable: false,
valign: 'middle',
},
['Log rate change']: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the Log rate change column be made sortable? I think the similar column in the anomalies table sorts by size of factor of increase / decrease.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in ff861eb
Since we have the pValue - which is an indication of the impact - I used that to sort 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dosen't look like pValue always correlates to the size of the change.

Screenshot 2024-06-21 at 11 54 38

I think the sortable prop can be ((item: T) => Primitive) as well as a simple boolean and then you can use logic like https://github.com/elastic/kibana/blob/main/x-pack/plugins/ml/server/models/results_service/build_anomaly_table_items.js#L105 to return the factor difference (or maybe you already know the change up front?).

const [skippedColumns, setSkippedColumns] = useState<ColumnNames[]>(['p-value']);
const [skippedColumns, setSkippedColumns] = useState<ColumnNames[]>([
'p-value',
'Baseline rate',
Copy link
Contributor

@peteharverson peteharverson Jun 19, 2024

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -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[]>([
Copy link
Contributor

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.

Copy link
Contributor

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.

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

This has been updated and is ready for another look when you get a chance 🙏 cc @peteharverson, @walterra

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave the latest changes a test. All looks good - only item to look at is the way sorting on the change column works.

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM.

@alvarezmelissa87
Copy link
Contributor Author

Gave the latest changes a test. All looks good - only item to look at is the way sorting on the change column works.

Thanks for taking a look, @peteharverson 🙏 Adding sorting for that computed Log rate change is a can of worms as it requires us to make some changes to the custom sorting we've got going on now and will likely require a bit of code churn.
For now, I've removed sorting for that column and added it as a follow up in #181111

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 630 631 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiops 554.2KB 558.7KB +4.5KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit 702442d into elastic:main Jun 24, 2024
25 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 24, 2024
@alvarezmelissa87 alvarezmelissa87 deleted the ml-aiops-additional-columns branch June 24, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis :ml release_note:enhancement v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants