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] Adds validation of field selected for log pattern analysis #162319

Merged

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Jul 20, 2023

Uses the recently created category validation package to perform validation on the field selected for pattern analysis.

If the field is considered unsuitable for categorization, a warning callout is displayed which lists the reasons it is unsuitable.
If the field is suitable, no callout is displayed.

Other changes:

  • Adds the selected field to the URL state, so it is remembered on page refresh.
  • If no field is in the URL, it will look for a field called message in the data view and auto select it.
  • renames the ML route /jobs/categorization_field_examples to /jobs/categorization_field_validation as it is a more accurate name and it's consistent with the newly added route in AIOPs.

Log Pattern Analysis page in ML

image

Log Pattern Analysis flyout in Discover

image

import { boomify, isBoom } from '@hapi/boom';
import { ResponseError, CustomHttpResponseOptions } from '@kbn/core/server';

export function wrapError(error: any): CustomHttpResponseOptions<ResponseError> {
Copy link
Member Author

Choose a reason for hiding this comment

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

A duplicate of the function in ML.
Could possibly be moved to a package if we ever need it in another plugin.

Copy link
Contributor

Choose a reason for hiding this comment

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

The same is already in multiple plugins. We already have @kbn/ml-error-utils and could move it there, but I think for now this package is only used for client side utils, so we need to refactor that to be split into server/client side code to not unnecessarily blow up client side bundle sizes.

@jgowdyelastic jgowdyelastic self-assigned this Jul 25, 2023
@jgowdyelastic jgowdyelastic added release_note:enhancement :ml Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis v8.10.0 labels Jul 25, 2023
@jgowdyelastic jgowdyelastic marked this pull request as ready for review July 25, 2023 11:36
@jgowdyelastic jgowdyelastic removed the request for review from a team July 27, 2023 09:37
@peteharverson peteharverson requested review from qn895 and removed request for alvarezmelissa87 July 27, 2023 16:27
import { i18n } from '@kbn/i18n';
import { isRuntimeField } from '@kbn/ml-runtime-field-utils';

export const runtimeMappingsSchema = schema.object(
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if we should add runtimeMappingsSchema to ml-runtime-field-utils as we do use it in several plugins 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved in 40fb370

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reverted this move. I caused a 200KB bundle increase in ML and Transforms.

@@ -217,6 +251,8 @@ export const LogCategorizationFlyout: FC<LogCategorizationPageProps> = ({
</EuiFlexGroup>
</EuiFlyoutHeader>
<EuiFlyoutBody data-test-subj="mlJobSelectorFlyoutBody">
<FieldValidationCallout validationResults={fieldValidationResult} />
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, looks like the callout isn't getting displayed if no categories are found - for example with field6 from the categorization_functional_test data set. In this case the field is populated so the message here is misleading:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

With this example, the field does not produce any warnings because the data is tokenized correctly but it also does not produce any categories. I suspect this is because every doc contains the same data.


return (
<>
{validationResults !== null ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Guess this ternary can be removed since the same check is done above and returns early.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 914c43d

import { boomify, isBoom } from '@hapi/boom';
import { ResponseError, CustomHttpResponseOptions } from '@kbn/core/server';

export function wrapError(error: any): CustomHttpResponseOptions<ResponseError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

The same is already in multiple plugins. We already have @kbn/ml-error-utils and could move it there, but I think for now this package is only used for client side utils, so we need to refactor that to be split into server/client side code to not unnecessarily blow up client side bundle sizes.

"@kbn/ml-date-picker",
"@kbn/ml-error-utils",
"@kbn/ml-is-defined",
"@kbn/ml-is-populated-object",
"@kbn/ml-kibana-theme",
"@kbn/ml-kibana-theme",
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate entry here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 914c43d

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

@qn895
Copy link
Member

qn895 commented Jul 28, 2023

LGTM 🎉

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 427 435 +8

Async chunks

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

id before after diff
aiops 531.6KB 535.2KB +3.6KB
ml 3.4MB 3.4MB +15.0B
total +3.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 73.8KB 73.9KB +22.0B
Unknown metric groups

API count

id before after diff
@kbn/ml-category-validator 32 37 +5

References to deprecated APIs

id before after diff
aiops 12 2 -10

History

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

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit 716ecb8 into elastic:main Jul 28, 2023
21 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 28, 2023
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.

Great you brought down the bundle size again, latest changes LGTM!

ThomThomson pushed a commit to ThomThomson/kibana that referenced this pull request Aug 1, 2023
Uses the recently created [category validation
package](elastic#161261) to perform
validation on the field selected for pattern analysis.

If the field is considered unsuitable for categorization, a warning
callout is displayed which lists the reasons it is unsuitable.
If the field is suitable, no callout is displayed.

Other changes:
- Adds the selected field to the URL state, so it is remembered on page
refresh.
- If no field is in the URL, it will look for a field called `message`
in the data view and auto select it.
- renames the ML route `/jobs/categorization_field_examples` to
`/jobs/categorization_field_validation` as it is a more accurate name
and it's consistent with the newly added route in AIOPs.

**Log Pattern Analysis page in ML**


![image](https://github.com/elastic/kibana/assets/22172091/c0dfda8b-bc34-48b7-9e71-8bae9e65bdf3)


**Log Pattern Analysis flyout in Discover**


![image](https://github.com/elastic/kibana/assets/22172091/b4d251f3-bae6-424f-9891-bda57ba1673d)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@peteharverson peteharverson changed the title [ML] Log pattern analysis field validation [ML] Adds validation of field selected for log pattern analysis Aug 21, 2023
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.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants