2017-06-20 09:23:58 +08:00
|
|
|
[role="xpack"]
|
2018-09-01 07:49:24 +08:00
|
|
|
[testenv="platinum"]
|
2017-04-05 06:26:39 +08:00
|
|
|
[[ml-close-job]]
|
2020-07-21 03:38:09 +08:00
|
|
|
= Close {anomaly-jobs} API
|
2017-12-15 02:52:49 +08:00
|
|
|
++++
|
2018-12-21 02:23:28 +08:00
|
|
|
<titleabbrev>Close jobs</titleabbrev>
|
2017-12-15 02:52:49 +08:00
|
|
|
++++
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-07-25 23:58:16 +08:00
|
|
|
Closes one or more {anomaly-jobs}.
|
2017-04-20 01:52:30 +08:00
|
|
|
|
2019-06-28 00:42:47 +08:00
|
|
|
[[ml-close-job-request]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-request-title}
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2018-12-08 04:34:11 +08:00
|
|
|
`POST _ml/anomaly_detectors/<job_id>/_close` +
|
2017-08-09 23:30:21 +08:00
|
|
|
|
2018-12-08 04:34:11 +08:00
|
|
|
`POST _ml/anomaly_detectors/<job_id>,<job_id>/_close` +
|
2017-08-09 23:30:21 +08:00
|
|
|
|
2018-12-08 04:34:11 +08:00
|
|
|
`POST _ml/anomaly_detectors/_all/_close` +
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-06-28 04:58:42 +08:00
|
|
|
[[ml-close-job-prereqs]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-prereq-title}
|
2019-06-28 04:58:42 +08:00
|
|
|
|
2021-05-03 16:20:14 +08:00
|
|
|
* Requires the `manage_ml` cluster privilege. This privilege is included in the
|
|
|
|
`machine_learning_admin` built-in role.
|
2019-06-28 04:58:42 +08:00
|
|
|
|
2019-06-28 00:42:47 +08:00
|
|
|
[[ml-close-job-desc]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-description-title}
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2021-08-26 02:35:21 +08:00
|
|
|
A job can be opened and closed multiple times throughout its lifecycle.
|
|
|
|
|
|
|
|
A closed job cannot receive data or perform analysis operations, but you can
|
|
|
|
still explore and navigate results.
|
|
|
|
|
2019-07-25 23:58:16 +08:00
|
|
|
You can close multiple {anomaly-jobs} in a single API request by using a group
|
|
|
|
name, a comma-separated list of jobs, or a wildcard expression. You can close
|
|
|
|
all jobs by using `_all` or by specifying `*` as the `<job_id>`.
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2021-08-26 02:35:21 +08:00
|
|
|
If you close an {anomaly-job} whose {dfeed} is running, the request first tries
|
|
|
|
to stop the {dfeed}. This behavior is equivalent to calling
|
|
|
|
<<ml-stop-datafeed,stop {dfeed}>> with the same `timeout` and `force` parameters
|
|
|
|
as the close job request.
|
2021-06-22 19:56:11 +08:00
|
|
|
|
2017-04-05 06:26:39 +08:00
|
|
|
When you close a job, it runs housekeeping tasks such as pruning the model history,
|
2017-04-12 09:52:47 +08:00
|
|
|
flushing buffers, calculating final results and persisting the model snapshots.
|
2017-04-05 06:26:39 +08:00
|
|
|
Depending upon the size of the job, it could take several minutes to close and
|
|
|
|
the equivalent time to re-open.
|
|
|
|
|
2017-04-20 01:52:30 +08:00
|
|
|
After it is closed, the job has a minimal overhead on the cluster except for
|
2017-04-25 02:14:58 +08:00
|
|
|
maintaining its meta data. Therefore it is a best practice to close jobs that
|
|
|
|
are no longer required to process data.
|
2017-04-20 01:52:30 +08:00
|
|
|
|
2017-05-03 03:45:42 +08:00
|
|
|
When a {dfeed} that has a specified end date stops, it automatically closes
|
2021-06-22 19:56:11 +08:00
|
|
|
its associated job.
|
2017-04-25 02:14:58 +08:00
|
|
|
|
2017-06-19 17:16:51 +08:00
|
|
|
NOTE: If you use the `force` query parameter, the request returns without performing
|
|
|
|
the associated actions such as flushing buffers and persisting the model snapshots.
|
|
|
|
Therefore, do not use this parameter if you want the job to be in a consistent state
|
2021-03-31 21:57:47 +08:00
|
|
|
after the close job API returns. The `force` query parameter should only be used in
|
2017-06-19 17:16:51 +08:00
|
|
|
situations where the job has already failed, or where you are not interested in
|
|
|
|
results the job might have recently produced or might produce in the future.
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-06-28 00:42:47 +08:00
|
|
|
[[ml-close-job-path-parms]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-path-parms-title}
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-07-12 23:26:31 +08:00
|
|
|
`<job_id>`::
|
2019-12-07 07:32:07 +08:00
|
|
|
(Required, string)
|
2020-06-02 02:46:10 +08:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-wildcard]
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-06-28 00:42:47 +08:00
|
|
|
[[ml-close-job-query-parms]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-query-parms-title}
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2020-08-05 18:29:07 +08:00
|
|
|
`allow_no_match`::
|
2020-10-29 21:04:43 +08:00
|
|
|
(Optional, Boolean)
|
2020-06-02 02:46:10 +08:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
|
2019-07-30 20:22:14 +08:00
|
|
|
|
2019-07-12 23:26:31 +08:00
|
|
|
`force`::
|
2020-10-29 21:04:43 +08:00
|
|
|
(Optional, Boolean) Use to close a failed job, or to forcefully close a job
|
2019-07-12 23:26:31 +08:00
|
|
|
which has not responded to its initial close request.
|
2017-04-20 01:52:30 +08:00
|
|
|
|
2019-07-12 23:26:31 +08:00
|
|
|
`timeout`::
|
2019-08-08 19:43:55 +08:00
|
|
|
(Optional, <<time-units, time units>>) Controls the time to wait until a job
|
|
|
|
has closed. The default value is 30 minutes.
|
2017-04-25 02:14:58 +08:00
|
|
|
|
2019-07-30 20:22:14 +08:00
|
|
|
[[ml-close-job-response-codes]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-response-codes-title}
|
2019-07-30 20:22:14 +08:00
|
|
|
|
|
|
|
`404` (Missing resources)::
|
2020-08-05 18:29:07 +08:00
|
|
|
If `allow_no_match` is `false`, this code indicates that there are no
|
2019-07-30 20:22:14 +08:00
|
|
|
resources that match the request or only partial matches for the request.
|
|
|
|
|
2019-06-28 00:42:47 +08:00
|
|
|
[[ml-close-job-example]]
|
2020-07-21 03:38:09 +08:00
|
|
|
== {api-examples-title}
|
2017-04-05 06:26:39 +08:00
|
|
|
|
2019-09-06 22:55:16 +08:00
|
|
|
[source,console]
|
2017-04-05 06:26:39 +08:00
|
|
|
--------------------------------------------------
|
2019-12-31 07:21:18 +08:00
|
|
|
POST _ml/anomaly_detectors/low_request_rate/_close
|
2017-04-05 06:26:39 +08:00
|
|
|
--------------------------------------------------
|
2020-10-19 17:17:27 +08:00
|
|
|
// TEST[skip:Kibana sample data]
|
2017-04-05 06:26:39 +08:00
|
|
|
|
|
|
|
When the job is closed, you receive the following results:
|
2019-09-06 04:47:18 +08:00
|
|
|
|
|
|
|
[source,console-result]
|
2017-04-05 06:26:39 +08:00
|
|
|
----
|
|
|
|
{
|
|
|
|
"closed": true
|
|
|
|
}
|
|
|
|
----
|