2017-06-19 21:23:58 -04:00
|
|
|
[role="xpack"]
|
2018-08-31 19:49:24 -04:00
|
|
|
[testenv="platinum"]
|
2017-04-04 18:26:39 -04:00
|
|
|
[[ml-flush-job]]
|
2020-07-20 16:10:54 -04:00
|
|
|
= Flush jobs API
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Flush jobs</titleabbrev>
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-06-13 16:37:35 -04:00
|
|
|
Forces any buffered data to be processed by the job.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-request]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-request-title}
|
2017-04-11 21:52:47 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`POST _ml/anomaly_detectors/<job_id>/_flush`
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[[ml-flush-job-prereqs]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-prereq-title}
|
2019-06-27 16:58:42 -04:00
|
|
|
|
|
|
|
* If the {es} {security-features} are enabled, you must have `manage_ml` or
|
|
|
|
`manage` cluster privileges to use this API. See
|
2020-07-23 19:43:10 -04:00
|
|
|
<<security-privileges>> and {ml-docs-setup-privileges}.
|
2019-06-27 16:58:42 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-desc]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-description-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-01-15 11:44:08 -05:00
|
|
|
The flush jobs API is only applicable when sending data for analysis using the
|
2017-04-25 17:08:29 -04:00
|
|
|
<<ml-post-data,post data API>>. Depending on the content of the buffer, then it
|
|
|
|
might additionally calculate new results.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-04-18 18:13:21 -04:00
|
|
|
Both flush and close operations are similar, however the flush is more efficient
|
2017-04-25 17:08:29 -04:00
|
|
|
if you are expecting to send more data for analysis. When flushing, the job
|
|
|
|
remains open and is available to continue analyzing data. A close operation
|
|
|
|
additionally prunes and persists the model state to disk and the job must be
|
|
|
|
opened again before analyzing further data.
|
2017-04-18 18:13:21 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-path-parms]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-path-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`<job_id>`::
|
2019-12-27 16:30:26 -05:00
|
|
|
(Required, string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
|
2017-04-25 17:08:29 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-query-parms]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-query-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`advance_time`::
|
|
|
|
(string) Optional. Specifies to advance to a particular time value. Results are
|
2018-02-19 14:04:12 -05:00
|
|
|
generated and the model is updated for data from the specified time interval.
|
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`calc_interim`::
|
|
|
|
(boolean) Optional. If true, calculates the interim results for the most
|
|
|
|
recent bucket or all buckets within the latency period.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`end`::
|
|
|
|
(string) Optional. When used in conjunction with `calc_interim`, specifies the
|
|
|
|
range of buckets on which to calculate interim results.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`skip_time`::
|
|
|
|
(string) Optional. Specifies to skip to a particular time value. Results are
|
|
|
|
not generated and the model is not updated for data from the specified time
|
2018-02-19 14:04:12 -05:00
|
|
|
interval.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`start`::
|
|
|
|
(string) Optional. When used in conjunction with `calc_interim`, specifies the
|
|
|
|
range of buckets on which to calculate interim results.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-example]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-examples-title}
|
2017-04-06 10:56:46 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2017-04-06 10:56:46 -04:00
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
POST _ml/anomaly_detectors/total-requests/_flush
|
2017-04-06 10:56:46 -04:00
|
|
|
{
|
|
|
|
"calc_interim": true
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2018-08-31 19:49:24 -04:00
|
|
|
// TEST[skip:setup:server_metrics_openjob]
|
2018-02-19 14:04:12 -05:00
|
|
|
|
|
|
|
When the operation succeeds, you receive the following results:
|
2019-09-06 16:09:09 -04:00
|
|
|
|
|
|
|
[source,console-result]
|
2018-02-19 14:04:12 -05:00
|
|
|
----
|
|
|
|
{
|
|
|
|
"flushed": true,
|
|
|
|
"last_finalized_bucket_end": 1455234900000
|
|
|
|
}
|
|
|
|
----
|
2018-08-31 19:49:24 -04:00
|
|
|
//TESTRESPONSE[s/"last_finalized_bucket_end": 1455234900000/"last_finalized_bucket_end": $body.last_finalized_bucket_end/]
|
2018-02-19 14:04:12 -05:00
|
|
|
|
|
|
|
The `last_finalized_bucket_end` provides the timestamp (in
|
|
|
|
milliseconds-since-the-epoch) of the end of the last bucket that was processed.
|
|
|
|
|
|
|
|
If you want to flush the job to a specific timestamp, you can use the
|
|
|
|
`advance_time` or `skip_time` parameters. For example, to advance to 11 AM GMT
|
|
|
|
on January 1, 2018:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2018-02-19 14:04:12 -05:00
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
POST _ml/anomaly_detectors/total-requests/_flush
|
2018-02-19 14:04:12 -05:00
|
|
|
{
|
2020-03-19 10:40:53 -04:00
|
|
|
"advance_time": "1514804400000"
|
2018-02-19 14:04:12 -05:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2018-08-31 19:49:24 -04:00
|
|
|
// TEST[skip:setup:server_metrics_openjob]
|
2017-04-06 10:56:46 -04:00
|
|
|
|
|
|
|
When the operation succeeds, you receive the following results:
|
2019-09-06 09:22:08 -04:00
|
|
|
|
|
|
|
[source,console-result]
|
2017-04-06 10:56:46 -04:00
|
|
|
----
|
|
|
|
{
|
2018-02-19 14:04:12 -05:00
|
|
|
"flushed": true,
|
|
|
|
"last_finalized_bucket_end": 1514804400000
|
2017-04-06 10:56:46 -04:00
|
|
|
}
|
|
|
|
----
|