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]]
|
2018-12-20 13:23:28 -05: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]]
|
|
|
|
==== {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]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* If the {es} {security-features} are enabled, you must have `manage_ml` or
|
|
|
|
`manage` cluster privileges to use this API. See
|
|
|
|
{stack-ov}/security-privileges.html[Security privileges].
|
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-desc]]
|
|
|
|
==== {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]]
|
|
|
|
==== {api-path-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
`<job_id>` (Required)::
|
|
|
|
(string) Identifier for the job.
|
2017-04-25 17:08:29 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-flush-job-query-parms]]
|
|
|
|
==== {api-query-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
`advance_time` (Optional)::
|
2018-02-19 14:04:12 -05:00
|
|
|
(string) Specifies to advance to a particular time value. Results are
|
|
|
|
generated and the model is updated for data from the specified time interval.
|
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
`calc_interim` (Optional)::
|
2018-02-19 14:04:12 -05:00
|
|
|
(boolean) 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-06-27 16:58:42 -04:00
|
|
|
`end` (Optional)::
|
2017-04-11 22:26:18 -04:00
|
|
|
(string) When used in conjunction with `calc_interim`, specifies the range
|
2017-04-11 21:52:47 -04:00
|
|
|
of buckets on which to calculate interim results.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
`skip_time` (Optional)::
|
2018-02-19 14:04:12 -05:00
|
|
|
(string) Specifies to skip to a particular time value. Results are not
|
|
|
|
generated and the model is not updated for data from the specified time
|
|
|
|
interval.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
`start` (Optional)::
|
2017-04-11 22:26:18 -04:00
|
|
|
(string) When used in conjunction with `calc_interim`, specifies the range of
|
2017-04-11 21:52:47 -04:00
|
|
|
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]]
|
|
|
|
==== {api-examples-title}
|
2017-04-06 10:56:46 -04:00
|
|
|
|
2018-02-19 14:04:12 -05:00
|
|
|
The following example flushes the `total-requests` job:
|
2017-04-06 10:56:46 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
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
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
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:
|
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"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:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
POST _ml/anomaly_detectors/total-requests/_flush
|
2018-02-19 14:04:12 -05:00
|
|
|
{
|
|
|
|
"advance_time": "1514804400"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
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:
|
2017-04-21 11:23:27 -04:00
|
|
|
[source,js]
|
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
|
|
|
}
|
|
|
|
----
|
2018-02-19 14:04:12 -05:00
|
|
|
// TESTRESPONSE
|