Skip to content

[ML] Anomaly Detection wizards: adds geo job wizard#147043

Merged
alvarezmelissa87 merged 12 commits intoelastic:mainfrom
alvarezmelissa87:ml-geo-job-wizard
Dec 12, 2022
Merged

[ML] Anomaly Detection wizards: adds geo job wizard#147043
alvarezmelissa87 merged 12 commits intoelastic:mainfrom
alvarezmelissa87:ml-geo-job-wizard

Conversation

@alvarezmelissa87
Copy link
Copy Markdown
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Dec 5, 2022

Summary

Adds geo job wizard for lat_long jobs.

image

image

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 marked this pull request as ready for review December 6, 2022 18:42
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner December 6, 2022 18:42
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/ml-ui (:ml)

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

Tagged you, @lcawl, for copy stuff 😄 🙏

…reator/geo_job_creator.ts

Co-authored-by: James Gowdy <jgowdy@elastic.co>
</EuiFlexGroup>
<EuiFlexGroup gutterSize="xl">
<EuiFlexItem>
<BucketSpan setIsValid={setIsValid} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the bucket span estimator currently work with lat_long jobs, and if not, is it possible to hide the 'Estimate bucket span' button from the wizard?

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look, @peteharverson. Looks like we also get this for rare jobs so might be worth looking into getting it working for the newer job wizards or removing that portion from all.
Happy to look at it in a follow up 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leave this for a follow-up. Could you raise an issue for it please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created an issue for this 👍

@peteharverson
Copy link
Copy Markdown
Contributor

peteharverson commented Dec 7, 2022

Not related to the changes here, but noticed the formatting of the values in the tooltip have &quot in them. Can we do anything about the formatting?

image

Good catch, @peteharverson
Added a fix in 410b861

image

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

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

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@szabosteve szabosteve left a comment

Choose a reason for hiding this comment

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

One suggestion, otherwise UI text LGTM.

description={
<FormattedMessage
id="xpack.ml.newJob.wizard.pickFieldsStep.geoField.description"
defaultMessage="Select a geo field. The lat_long function detects anomalies in the geographic location of the input data."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="Select a geo field. The lat_long function detects anomalies in the geographic location of the input data."
defaultMessage="Select a geo field to detect anomalies in the geographic location of the input data."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 9be34fe

this._geoAgg = geo;
}

public set geoField(field: Field | null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks like this setter isn't needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 9be34fe

return dtr;
}

public removeDetector(index: number) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this function isn't needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 9be34fe

return this._splitField;
}

public addDetector(agg: Aggregation, field: Field) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks like this function isn't needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 9be34fe

return;
}
const agg = this._geoAgg!;
if (this._detectors.length === 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove addDetector and simplify this logic to:

this.removeAllDetectors();
const dtr = this._createDetector(agg, field);
this._addDetector(dtr, agg, field);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated in 9be34fe

const eq = (newArgs: any[], lastArgs: any[]) => isEqual(newArgs, lastArgs);

export class MapLoader extends ChartLoader {
private _indexPatternId: string | undefined;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should changes the base class to store the whole "indexPattern" naming it the _dataView and remove the _indexPatternTitle and _indexPatternId member variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call- updated in 9be34fe

}
setIsValid(valid);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [jobCreatorUpdated, jobCreator.geoField]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if we're watching jobCreatorUpdated we shouldn't need to also watch jobCreator.geoField.
I know this seems counter intuitive, as really we should be watching all dependencies, but these wizards are designed around jobCreatorUpdated being the single notification that changes have happened.
So for consistency with the other components, I think we should only watch jobCreatorUpdated here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👌 Thanks for the context - updated in 9be34fe

@@ -0,0 +1,40 @@
/*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For consistency with other components, I think description.tsx, geo_field_select.tsx and geo_field.tsx should be moved out one level into a folder called geo_field.
So it is the same as population_field, rare_field, split_field etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved in 9be34fe

Copy link
Copy Markdown
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.

Tested latest changes and LGTM

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

Apologies - this has been updated with latest recommendations and is ready for a final look 🙏 cc @jgowdyelastic, @peteharverson

@lcawl
Copy link
Copy Markdown
Contributor

lcawl commented Dec 9, 2022

Just a drive-by comment: Per https://www.elastic.co/guide/en/machine-learning/current/ml-geo-functions.html, "
You cannot create forecasts for anomaly detection jobs that contain geographic functions. You also cannot add rules with conditions to detectors that use geographic functions." It might be nice to include that type of information (e.g. on the last page of the wizard?). Otherwise, I think users only learn about these limitations when they try and fail to accomplish those tasks.

description={
<FormattedMessage
id="xpack.ml.newJob.wizard.pickFieldsStep.geoField.description"
defaultMessage="Select a geo field to detect anomalies in the geographic location of the input data."
Copy link
Copy Markdown
Contributor

@lcawl lcawl Dec 9, 2022

Choose a reason for hiding this comment

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

     defaultMessage="Select a geo field to detect anomalies in the geographic location of the input data."

Per https://www.elastic.co/guide/en/machine-learning/current/ml-geo-functions.html, "The field_name that you supply must be a single string that contains two comma-separated numbers of the form latitude,longitude, a geo_point field, a geo_shape field that contains point values, or a geo_centroid aggregation. The latitude and longitude must be in the range -180 to 180 and represent a point on the surface of the Earth." I presume this wizard filters the possible field values to only those that meet these requirements. If not, however, it might be helpful to include this type of information in a tip (in case a user thinks they have geo data and it isn't showing up because it doesn't meet these requirements).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The wizard does only show supported fields already - and also the wizard option only shows up if there are fields that are supported by this type of job so the user wouldn't be running into any situations in which there would be no fields in the dropdown.
🤔 We could still add a tooltip with info about the fields just for information sake, though I don't think it's necessary for this PR. Happy to add in follow up

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

Just a drive-by comment: Per https://www.elastic.co/guide/en/machine-learning/current/ml-geo-functions.html, " You cannot create forecasts for anomaly detection jobs that contain geographic functions. You also cannot add rules with conditions to detectors that use geographic functions." It might be nice to include that type of information (e.g. on the last page of the wizard?). Otherwise, I think users only learn about these limitations when they try and fail to accomplish those tasks.

That's a good point, @lcawl 🤔 I think that's a good idea and would be good to add for the other specific wizards as well (if it's not in there already). Sounds like one for a follow up.

Copy link
Copy Markdown
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1577 1591 +14

Async chunks

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

id before after diff
ml 3.4MB 3.4MB +9.4KB
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 60 66 +6
ml 558 566 +8
osquery 109 115 +6
securitySolution 445 451 +6
total +28

References to deprecated APIs

id before after diff
ml 249 244 -5

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 69 75 +6
ml 561 569 +8
osquery 110 117 +7
securitySolution 521 527 +6
total +29

History

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

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit 95902fa into elastic:main Dec 12, 2022
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Dec 12, 2022
@alvarezmelissa87 alvarezmelissa87 deleted the ml-geo-job-wizard branch December 12, 2022 21:15
@peteharverson peteharverson added release_note:feature Makes this part of the condensed release notes and removed release_note:enhancement labels Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Anomaly Detection ML anomaly detection :ml release_note:feature Makes this part of the condensed release notes v8.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants