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] Jobs import and export #101037

Merged
merged 52 commits into from Jul 22, 2021

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Jun 1, 2021

Adding export and import of anomaly detection and data frame analytics jobs to the ML section of the Stack Management page.
An exported job file contains a single or array of job configs. In the case of anomaly detector jobs, a wrapping object is used to contain the job and datafeed e.g.

[
  {
    "job: {...}
    "datafeed": {...}
  }
]

Export
2021-07-15 12-01-33 2021-07-15 12_02_45

Import
2021-07-15 12-03-16 2021-07-15 12_05_52

When an anomaly detection file has been selected, the indices in the datafeed are checked to ensure that matching index patterns exist. This is based on a requirement of the new job wizards where index patterns need to exist in order to clone a job.

image

Selecting a file which does not contain valid ML jobs or contains a mixture of anomaly detection and data frame analytic jobs will cause an error:
image

Also adds a new bulk create endpoint for anomaly detection jobs which takes the same shaped payload as the exported file format.

POST /api/ml/jobs/bulk_create

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic jgowdyelastic changed the title [ML] Jobs import and export [ML] WIP Jobs import and export Jun 8, 2021
@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

Still seeing the same 400 error dest index must be empty when trying to start an imported DFA job even when destination index was edited in the import flyout. Looks like the destination index isn't actually getting updated before the job is imported.

What do you think about having the help text in the dest index editor let the user know that the job start will fail if they don't change the destination index?


@alvarezmelissa87

cf29161 fixes the dest index not being saved.

What do you think about having the help text in the dest index editor let the user know that the job start will fail if they don't change the destination index?

This is not what the help text lead me to believe in the DFA wizard. The warning text I'm showing is copied from the DFA wizard and is purposefully not an invalid state in the importer.
Do you think this needs to change and if a destination index already exists it should stop the user from importing?
The exists check could check to see if the index is empty too. This change would need to go into the DFA wizard too.

x-pack/plugins/ml/common/types/job_service.ts Outdated Show resolved Hide resolved
const blob = new Blob([JSON.stringify(configsForExport, null, 2)], {
type: 'application/json',
});
saveAs(blob, 'ml_jobs.json');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think it might be convenient to have jobs type, stack version, and date in the file name, something like anomaly_detection_ml_jobs_7.14.0_20210808

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is a good idea to give these files a more specific name.
I've made a change here 330129a so the files are now either anomaly_detection_jobs.json or data_frame_analytics_jobs.json.

There are problems with adding the version to the file name as it may be coming from a mixed version cluster.
For now I think these names are definitely an improvement and we can make changes later on if we decide we should add more information.

x-pack/plugins/ml/server/routes/system.ts Outdated Show resolved Hide resolved
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.

Code LGTM. I reckon it's worth adding some telemetry for this feature in a follow-up.

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]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1729 1741 +12

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
apm 39 - -39
banners 9 - -9
core 1080 - -1080
maps 203 - -203
metricsEntities 6 - -6
ml 274 - -274
monitoring 10 - -10
observability 219 - -219
osquery 11 - -11
remoteClusters 4 - -4
reporting 132 - -132
rollup 20 - -20
ruleRegistry 60 - -60
runtimeFields 19 - -19
savedObjectsTagging 50 - -50
security 51 - -51
securitySolution 1130 - -1130
snapshotRestore 22 - -22
stackAlerts 4 - -4
taskManager 25 - -25
telemetryCollectionXpack 1 - -1
timelines 763 - -763
triggersActionsUi 228 - -228
uiActionsEnhanced 147 - -147
total -4507

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
core 148 - -148
maps 2 - -2
ml 10 - -10
reporting 1 - -1
securitySolution 8 - -8
snapshotRestore 1 - -1
timelines 6 - -6
triggersActionsUi 1 - -1
uiActionsEnhanced 2 - -2
total -179

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 +43.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
apm 30 - -30
core 31 - -31
maps 11 - -11
metricsEntities 1 - -1
ml 33 - -33
monitoring 2 - -2
observability 10 - -10
reporting 14 - -14
ruleRegistry 9 - -9
runtimeFields 2 - -2
security 6 - -6
securitySolution 28 - -28
snapshotRestore 1 - -1
taskManager 8 - -8
timelines 25 - -25
triggersActionsUi 19 - -19
uiActionsEnhanced 10 - -10
total -240
Unknown metric groups

API count

id before after diff
apm 39 - -39
banners 9 - -9
core 2359 - -2359
maps 204 - -204
metricsEntities 9 - -9
ml 278 - -278
monitoring 10 - -10
observability 219 - -219
osquery 11 - -11
remoteClusters 4 - -4
reporting 133 - -133
rollup 20 - -20
ruleRegistry 60 - -60
runtimeFields 24 - -24
savedObjectsTagging 54 - -54
security 112 - -112
securitySolution 1181 - -1181
snapshotRestore 23 - -23
spaces 106 - -106
stackAlerts 4 - -4
taskManager 52 - -52
telemetryCollectionXpack 1 - -1
timelines 882 - -882
triggersActionsUi 237 - -237
uiActionsEnhanced 205 - -205
total -6236

References to deprecated APIs

id before after diff
apm 7 - -7
maps 592 - -592
ml 140 - -140
observability 34 - -34
security 2 - -2
securitySolution 919 - -919
stackAlerts 104 - -104
timelines 76 - -76
transform 16 - -16
uptime 11 - -11
urlDrilldown 18 - -18
total -1919

History

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

cc @jgowdyelastic

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 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 jgowdyelastic merged commit d9e236b into elastic:master Jul 22, 2021
@jgowdyelastic jgowdyelastic deleted the job-import-and-export branch July 22, 2021 14:57
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jul 22, 2021
* [ML] Jobs import and export

* adding dfa job import/export

* job id validation

* fixing conflicts

* adding index pattern validation

* updates to job list

* validation changes

* refactoring job id editing

* validating check

* file read error

* translation ids

* duplicate translation id

* small fix

* updating route and schema

* code clean up

* catching and displaying job creation errors

* useMemo for notifications

* small refactor

* cleaning up types

* adding job import success toast

* adding exporting toast

* small changes based on review

* adding loading spinner

* changing util files to services

* code changes baased on review

* adding missing bind change

* file rename

* adding confirm for tab changes

* adding destination index checks

* grouping import errors

* fixing translation ids

* fixing dest index update

* small changes based on review

* renaming exported file name

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.

kibanamachine added a commit that referenced this pull request Jul 22, 2021
* [ML] Jobs import and export

* adding dfa job import/export

* job id validation

* fixing conflicts

* adding index pattern validation

* updates to job list

* validation changes

* refactoring job id editing

* validating check

* file read error

* translation ids

* duplicate translation id

* small fix

* updating route and schema

* code clean up

* catching and displaying job creation errors

* useMemo for notifications

* small refactor

* cleaning up types

* adding job import success toast

* adding exporting toast

* small changes based on review

* adding loading spinner

* changing util files to services

* code changes baased on review

* adding missing bind change

* file rename

* adding confirm for tab changes

* adding destination index checks

* grouping import errors

* fixing translation ids

* fixing dest index update

* small changes based on review

* renaming exported file name

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: Automatically backport this PR after it's merged Feature:Anomaly Detection ML anomaly detection Feature:Data Frame Analytics ML data frame analytics features :ml release_note:feature Makes this part of the condensed release notes review v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants