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-get-bucket]]
|
2018-12-20 13:23:28 -05:00
|
|
|
=== Get buckets API
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Get buckets</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
|
|
|
Retrieves job results for one or more buckets.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-request]]
|
|
|
|
==== {api-request-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`GET _ml/anomaly_detectors/<job_id>/results/buckets` +
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`GET _ml/anomaly_detectors/<job_id>/results/buckets/<timestamp>`
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[[ml-get-bucket-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* If the {es} {security-features} are enabled, you must have `monitor_ml`,
|
|
|
|
`monitor`, `manage_ml`, or `manage` cluster privileges to use this API. You also
|
|
|
|
need `read` index privilege on the index that stores the results. The
|
|
|
|
`machine_learning_admin` and `machine_learning_user` roles provide these
|
|
|
|
privileges. For more information, see
|
|
|
|
{stack-ov}/security-privileges.html[Security privileges] and
|
|
|
|
{stack-ov}/built-in-roles.html[Built-in roles].
|
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-desc]]
|
|
|
|
==== {api-description-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-01-15 11:44:08 -05:00
|
|
|
The get buckets API presents a chronological view of the records, grouped by
|
|
|
|
bucket.
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-path-parms]]
|
|
|
|
==== {api-path-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`<job_id>`::
|
|
|
|
(Required, string) Identifier for the job
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`<timestamp>`::
|
|
|
|
(Optional, string) The timestamp of a single bucket result. If you do not
|
|
|
|
specify this parameter, the API returns information about all buckets.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-request-body]]
|
|
|
|
==== {api-request-body-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`anomaly_score`::
|
|
|
|
(Optional, double) Returns buckets with anomaly scores greater or equal than
|
|
|
|
this value.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`desc`::
|
|
|
|
(Optional, boolean) If true, the buckets are sorted in descending order.
|
2017-05-18 11:40:54 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`end`::
|
|
|
|
(Optional, string) Returns buckets with timestamps earlier than this time.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`exclude_interim`::
|
|
|
|
(Optional, boolean) If true, the output excludes interim results. By default,
|
|
|
|
interim results are included.
|
2017-04-24 13:46:17 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`expand`::
|
|
|
|
(Optional, boolean) If true, the output includes anomaly records.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`page`::
|
2017-05-08 09:53:04 -04:00
|
|
|
`from`:::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Optional, integer) Skips the specified number of buckets.
|
2017-05-08 09:53:04 -04:00
|
|
|
`size`:::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Optional, integer) Specifies the maximum number of buckets to obtain.
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`sort`::
|
|
|
|
(Optional, string) Specifies the sort field for the requested buckets. By
|
|
|
|
default, the buckets are sorted by the `timestamp` field.
|
2017-05-18 11:40:54 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`start`::
|
|
|
|
(Optional, string) Returns buckets with timestamps after this time.
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-results]]
|
|
|
|
==== {api-response-body-title}
|
2017-04-10 19:14:26 -04:00
|
|
|
|
|
|
|
The API returns the following information:
|
|
|
|
|
|
|
|
`buckets`::
|
2017-04-11 22:26:18 -04:00
|
|
|
(array) An array of bucket objects. For more information, see
|
2017-04-10 19:14:26 -04:00
|
|
|
<<ml-results-buckets,Buckets>>.
|
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-bucket-example]]
|
|
|
|
==== {api-examples-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-04-10 19:14:26 -04:00
|
|
|
The following example gets bucket information for the `it-ops-kpi` job:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
GET _ml/anomaly_detectors/it-ops-kpi/results/buckets
|
2017-04-10 19:14:26 -04:00
|
|
|
{
|
|
|
|
"anomaly_score": 80,
|
|
|
|
"start": "1454530200001"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[skip:todo]
|
|
|
|
|
|
|
|
In this example, the API returns a single result that matches the specified
|
|
|
|
score and time constraints:
|
2017-04-21 11:23:27 -04:00
|
|
|
[source,js]
|
2017-04-04 18:26:39 -04:00
|
|
|
----
|
|
|
|
{
|
|
|
|
"count": 1,
|
2017-04-10 19:14:26 -04:00
|
|
|
"buckets": [
|
|
|
|
{
|
2017-04-04 18:26:39 -04:00
|
|
|
"job_id": "it-ops-kpi",
|
2017-04-10 19:14:26 -04:00
|
|
|
"timestamp": 1454943900000,
|
2017-04-11 21:52:47 -04:00
|
|
|
"anomaly_score": 94.1706,
|
2017-04-10 19:14:26 -04:00
|
|
|
"bucket_span": 300,
|
2017-04-11 21:52:47 -04:00
|
|
|
"initial_anomaly_score": 94.1706,
|
2017-04-10 19:14:26 -04:00
|
|
|
"event_count": 153,
|
|
|
|
"is_interim": false,
|
|
|
|
"bucket_influencers": [
|
|
|
|
{
|
|
|
|
"job_id": "it-ops-kpi",
|
|
|
|
"result_type": "bucket_influencer",
|
|
|
|
"influencer_field_name": "bucket_time",
|
2017-04-11 21:52:47 -04:00
|
|
|
"initial_anomaly_score": 94.1706,
|
|
|
|
"anomaly_score": 94.1706,
|
|
|
|
"raw_anomaly_score": 2.32119,
|
|
|
|
"probability": 0.00000575042,
|
2017-04-10 19:14:26 -04:00
|
|
|
"timestamp": 1454943900000,
|
|
|
|
"bucket_span": 300,
|
|
|
|
"is_interim": false
|
|
|
|
}
|
|
|
|
],
|
2017-04-11 21:52:47 -04:00
|
|
|
"processing_time_ms": 2,
|
2017-04-10 19:14:26 -04:00
|
|
|
"partition_scores": [],
|
|
|
|
"result_type": "bucket"
|
2017-04-04 18:26:39 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
----
|