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] Switching to new datafeed preview #101780

Merged

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Jun 9, 2021

All datafeed previews in the UI now use the elasticsearch datafeed preview endpoint.
Related to elastic/elasticsearch#70836

image

Also fixes a recently introduced bug where the Test button when adding a custom url to a job which doesn't exist or hasn't been run will throw an error.

Checklist

Delete any items that are not applicable to this PR.

@jgowdyelastic jgowdyelastic self-assigned this Jun 9, 2021
@jgowdyelastic jgowdyelastic added :ml auto-backport Deprecated - use backport:version if exact versions are needed Feature:Anomaly Detection ML anomaly detection release_note:enhancement review v7.14.0 v8.0 labels Jun 9, 2021
@jgowdyelastic jgowdyelastic marked this pull request as ready for review June 9, 2021 15:18
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner June 9, 2021 15:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Comment on lines 297 to 299
} catch (error) {
// search may fail if the job doesn't already exist
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to check for a particular error code/message here? otherwise it might silently fail unintentionally

Copy link
Member Author

@jgowdyelastic jgowdyelastic Jun 9, 2021

Choose a reason for hiding this comment

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

Failures here will cause failures later on which will be caught by the calling function and displayed to the user in a toast.
I also am not sure what errors we'd need to check for and accept.
This is also a feature that isn't used that much. It has been broken for a long time and no one has noticed.

Comment on lines 318 to 320
} catch (error) {
// jobs may not exist as this might be called from the AD job wizards
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to check for a particular error code/message here? otherwise, it might silently fail unintentionally.

Comment on lines 112 to 116
export const datafeedPreviewSchema = schema.object({
job: schema.maybe(schema.object(anomalyDetectionJobSchema)),
datafeed: schema.maybe(datafeedConfigSchema),
datafeedId: schema.maybe(schema.string()),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need a custom validation callback for this schema because you have mutually exclusive properties.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you know of an example I can copy?

Copy link
Member Author

Choose a reason for hiding this comment

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

the previous version using schema.oneOf i think was ok, but it caused other type errors

Copy link
Member Author

Choose a reason for hiding this comment

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

found this one

Copy link
Contributor

Choose a reason for hiding this comment

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

@jgowdyelastic yes, something like this

Copy link
Member Author

Choose a reason for hiding this comment

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

added in f895bb1

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM


setPreviewJsonString(JSON.stringify(data, null, 2));
const { datafeed_config: datafeed, ...job } = combinedJob;
const preview = await datafeedPreview(undefined, job, datafeed);
Copy link
Contributor

Choose a reason for hiding this comment

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

Before adding a detector, the flyout now shows this. Maybe it would be better not to run the preview before adding a detector? The previous approach showed docs with timestamps.

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.

I've added a check for the detectors list. if it is empty the preview isn't run and and a message is shown.

image

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@spalger spalger added v8.0.0 and removed v8.0 labels Jun 10, 2021
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.

Tested latest changes and LGTM

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
ml 5.9MB 5.9MB -259.0B

Page load bundle

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

id before after diff
ml 66.1KB 65.8KB -262.0B

History

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

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit f6ce964 into elastic:master Jun 14, 2021
@jgowdyelastic jgowdyelastic deleted the switching-to-new-datafeed-preview branch June 14, 2021 11:31
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 101780

jgowdyelastic added a commit that referenced this pull request Jun 14, 2021
* [ML] Switching to new datafeed preview

* fixing wizard test button

* adding schema validator

* fixing tests

* adding check for empty detectors list

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.js
cuff-links pushed a commit to cuff-links/kibana that referenced this pull request Jun 15, 2021
* [ML] Switching to new datafeed preview

* fixing wizard test button

* adding schema validator

* fixing tests

* adding check for empty detectors list

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Anomaly Detection ML anomaly detection :ml release_note:enhancement review v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants