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
|
|
|
|
2017-04-25 17:08:29 -04:00
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Request
|
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
|
|
|
|
2017-04-25 17:08:29 -04:00
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Description
|
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
|
|
|
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Path Parameters
|
2017-04-04 18:26:39 -04:00
|
|
|
|
|
|
|
`job_id` (required)::
|
2017-04-25 17:08:29 -04:00
|
|
|
(string) Identifier for the job
|
|
|
|
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Query Parameters
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-04-11 21:52:47 -04:00
|
|
|
`advance_time`::
|
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.
|
|
|
|
|
|
|
|
`calc_interim`::
|
|
|
|
(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
|
|
|
|
|
|
|
`end`::
|
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
|
|
|
|
2018-02-19 14:04:12 -05:00
|
|
|
`skip_time`::
|
|
|
|
(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
|
|
|
|
2017-04-11 21:52:47 -04:00
|
|
|
`start`::
|
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
|
|
|
|
2017-04-25 17:08:29 -04:00
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Authorization
|
2017-04-25 17:08:29 -04:00
|
|
|
|
|
|
|
You must have `manage_ml`, or `manage` cluster privileges to use this API.
|
2017-06-19 21:23:58 -04:00
|
|
|
For more information, see {xpack-ref}/security-privileges.html[Security Privileges].
|
2017-04-25 17:08:29 -04:00
|
|
|
|
|
|
|
|
2017-06-06 16:42:47 -04:00
|
|
|
==== Examples
|
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
|