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] Adding ability to change data view in advanced job wizard #115191

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Oct 15, 2021

Adds a new setting to the Advanced Job Wizard to allow the user to change the selected data view.
Problems may occur if the newly selected data view does not contain the fields are being used in the job, therefore we run a datafeed preview to validate that the current job works with the selected data view before applying it.

We would not expect the user to use this feature when creating a brand new job from scratch, as the data view is selected moments before the wizard opens. However, this feature is useful for users who need to adjust an existing job by allowing them to clone the job and then change the data view.

@szabosteve could you please review the text used in the UI.

Note, screenshots below use the term "Data view", this has now been changed to "Index pattern"

image

image

There are 4 validation results

The job does not contain any detectors and so validation is skipped.
image

Datafeed preview ran successfully and produced results
image

Datafeed preview ran successfully but no results were produced, this may be due to the index being empty.
image

The datafeed preview failed to run. Most probably the job contains fields which do not exist in the newly selected data view
image

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic jgowdyelastic self-assigned this Oct 18, 2021
@jgowdyelastic jgowdyelastic added :ml auto-backport Deprecated - use backport:version if exact versions are needed Feature:Anomaly Detection ML anomaly detection release_note:feature Makes this part of the condensed release notes review v7.16.0 v8.0.0 labels Oct 18, 2021
@jgowdyelastic jgowdyelastic marked this pull request as ready for review October 18, 2021 10:05
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner October 18, 2021 10:05
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

description={
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.description"
defaultMessage="The currently selected Data view being used for this job. Change this text."
Copy link
Contributor

Choose a reason for hiding this comment

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

data view. Are you looking for a suggestion from @szabosteve for the last part of this message?

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 489f0e3 to remove the change this text part, but yes, all text in this PR needs review please @szabosteve

@peteharverson
Copy link
Contributor

peteharverson commented Oct 18, 2021

The warning text at the bottom of the JSON editor can probably be changed too, to say something like The datafeed indices can be changed by editing the data view on the first step of the wizard.

image


@peteharverson updated in c89ca51

Also changes all uses of "data view" to "index pattern"

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 for the principal use case of editing the index pattern for a job created in the advanced wizard and looks good overall. Just left some suggestions for the text.

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

I left a couple of suggestions. Please let me know if you have any questions or requests.

>
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.validation.noDetectors.message"
defaultMessage="No detectors have been configured, so changing to this data view should be ok."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="No detectors have been configured, so changing to this data view should be ok."
defaultMessage="No detectors have been configured; this data view can be applied to the job."

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 0336d02

>
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.validation.valid.message"
defaultMessage="This data view appears to be a good match for this job."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="This data view appears to be a good match for this job."
defaultMessage="This data view can be applied to this job."

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 0336d02

>
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.validation.possiblyInvalid.message"
defaultMessage="This data view produced no results when previewing the datafeed. This could be due to there being no documents in {dataViewTitle}."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="This data view produced no results when previewing the datafeed. This could be due to there being no documents in {dataViewTitle}."
defaultMessage="This data view produced no results when previewing the datafeed. There might be no documents in {dataViewTitle}."

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 0336d02

>
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.validation.invalid.message"
defaultMessage="This data view produced an error when attempting to preview the datafeed. This could be due to fields selected for this job not existing in {dataViewTitle}."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="This data view produced an error when attempting to preview the datafeed. This could be due to fields selected for this job not existing in {dataViewTitle}."
defaultMessage="This data view produced an error when attempting to preview the datafeed. The fields selected for this job might not exist in {dataViewTitle}."

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 0336d02

<EuiCallOut color="warning">
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.step0.description"
defaultMessage="Changing the current data view may cause problems with the current job configuration as it may not contain the same fields."
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 the it in the second part of the sentence refers to the data view that the user wants to switch to. If my assumption is correct, then I suggest a clarification. Let me know if I misinterpret the sentence, please.

Suggested change
defaultMessage="Changing the current data view may cause problems with the current job configuration as it may not contain the same fields."
defaultMessage="Changing the current data view may cause problems with the corresponding job configuration as the newly selected data view may not contain the same fields."

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 0336d02

<>
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.step1.title"
defaultMessage="Select new data view for job"
Copy link
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 new data view for job"
defaultMessage="Select new data view for the job"

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 0336d02

<EuiLoadingSpinner />
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.step2.validatingText"
defaultMessage=" Checking compatibility of data view with job"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage=" Checking compatibility of data view with job"
defaultMessage=" Checking data view and job compatibility"

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 0336d02

description={
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.description"
defaultMessage="The currently selected data view being used for this job."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultMessage="The currently selected data view being used for this job."
defaultMessage="The data view that is currently used for this job."

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 0336d02

@@ -204,7 +204,7 @@ export const JsonEditorFlyout: FC<Props> = ({ isDisabled, jobEditorMode, datafee
>
<FormattedMessage
id="xpack.ml.newJob.wizard.jsonFlyout.indicesChange.calloutText"
defaultMessage="It is not possible to alter the indices being used by the datafeed here. If you wish to select a different index pattern or saved search, please start the job creation again, selecting a different index pattern."
defaultMessage="It is not possible to alter the indices being used by the datafeed here. If you wish to select a different index pattern or saved search, please jump to step 1 of the wizard and select change index pattern."
Copy link
Contributor

@szabosteve szabosteve Oct 18, 2021

Choose a reason for hiding this comment

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

Somehow I missed this part, I think it was updated while I was reviewing the PR.

Suggested change
defaultMessage="It is not possible to alter the indices being used by the datafeed here. If you wish to select a different index pattern or saved search, please jump to step 1 of the wizard and select change index pattern."
defaultMessage="You cannot alter the indices being used by the datafeed here. To select a different index pattern or saved search, go to step 1 of the wizard and select the Change index pattern option."

Copy link
Contributor

Choose a reason for hiding this comment

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

Another option if you want it shorter:

You cannot alter ... To select a different index pattern or saved search, go to step 1...

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better. I updated my suggestion accordingly.

<EuiCallOut color="warning">
<FormattedMessage
id="xpack.ml.newJob.wizard.datafeedStep.dataView.step0.description"
defaultMessage="Changing the current index pattern may cause problems with the corresponding job configuration as the newly selected index pattern may not contain the same fields."
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the current index pattern may cause problems with the corresponding job configuration as the newly selected index pattern may not contain the same fields.

Drive-by comment that it's unclear what the user is supposed to do with this message. Is it really necessary at this stage? IMO it would be more helpful to qualify only the error/warning checks' messages with something like: "If you apply this change, the mismatch between the index pattern and the job configuration might cause.... the job to fail? the analysis to be incorrect? (whatever the consequences are that we're trying to warn folks about there)".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I agree, this first warning step was added last minute, but I don't think it's needed.
I've removed it in f161ef4

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

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

Great to see the tests coming as part of this PR 🎉
Left a few comments.

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

const indices = title.split(',');
if (jobCreator.detectors.length) {
const datafeed: Datafeed = { ...jobCreator.datafeedConfig, indices };
const gg = await validateDatafeedPreview({
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we rename this variable?

Suggested change
const gg = await validateDatafeedPreview({
const validationResponse = await validateDatafeedPreview({

Copy link
Member Author

Choose a reason for hiding this comment

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

ha!! gg and hh are my go to names for variables when halfway through writing something.

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 35edeee

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

Functional tests LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1683 1687 +4

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.6MB 3.6MB +6.4KB

History

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

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit 92e1cd2 into elastic:master Oct 19, 2021
@jgowdyelastic jgowdyelastic deleted the adding-ability-to-change-data-view-in-advanced-job-wizard branch October 19, 2021 14:51
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 19, 2021
…ic#115191)

* [ML] Adding ability to change data view in advanced job wizard

* updating translation ids

* type and text changes

* code clean up

* route id change

* text changes

* text change

* changing data view to index pattern

* adding api tests

* text updates

* removing first step

* renaming temp variable

* adding permission checks

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

jloleysens added a commit to jloleysens/kibana that referenced this pull request Oct 19, 2021
…-link-to-kibana-app

* 'master' of github.com:elastic/kibana: (30 commits)
  Fix potential error from undefined (elastic#115562)
  [App Search, Crawler] Fix validation step panel padding/whitespace (elastic#115542)
  [Cases][Connectors] ServiceNow ITOM: MVP (elastic#114125)
  Change default session idle timeout to 8 hours. (elastic#115565)
  Upgrade EUI to v39.1.1 (elastic#114732)
  [App Search] Wired up organic results on Curation Suggestions view (elastic#114717)
  [i18n] remove i18n html extractor (elastic#115004)
  [Logs/Metrics UI] Add deprecated field configuration to Deprecations API (elastic#115103)
  [Transform] Add alerting rules management to Transform UI (elastic#115363)
  Update UI links to Fleet and Agent docs (elastic#115295)
  [ML] Adding ability to change data view in advanced job wizard (elastic#115191)
  Change deleteByNamespace to include legacy URL aliases (elastic#115459)
  [Unified Integrations] Remove and cleanup add data views (elastic#115424)
  [Discover] Show ignored field values (elastic#115040)
  [ML] Stop reading the ml.max_open_jobs node attribute (elastic#115524)
  [Discover] Improve doc viewer code in Discover (elastic#114759)
  [Security Solutions] Adds security detection rule actions as importable and exportable (elastic#115243)
  [Security Solution] [Platform] Migrate legacy actions whenever user interacts with the rule (elastic#115101)
  [Fleet] Add telemetry for integration cards (elastic#115413)
  🐛 Fix single percentile case when ES is returning no buckets (elastic#115214)
  ...

# Conflicts:
#	x-pack/plugins/reporting/public/management/__snapshots__/report_listing.test.tsx.snap
kibanamachine added a commit that referenced this pull request Oct 19, 2021
…) (#115585)

* [ML] Adding ability to change data view in advanced job wizard

* updating translation ids

* type and text changes

* code clean up

* route id change

* text changes

* text change

* changing data view to index pattern

* adding api tests

* text updates

* removing first step

* renaming temp variable

* adding permission checks

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: James Gowdy <jgowdy@elastic.co>
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:feature Makes this part of the condensed release notes review v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants