2017-10-10 09:41:24 -04:00
|
|
|
[role="xpack"]
|
2018-08-31 19:49:24 -04:00
|
|
|
[testenv="platinum"]
|
2017-10-10 09:41:24 -04:00
|
|
|
[[ml-get-overall-buckets]]
|
2018-12-20 13:23:28 -05:00
|
|
|
=== Get overall buckets API
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Get overall buckets</titleabbrev>
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-30 13:52:23 -04:00
|
|
|
Retrieves overall bucket results that summarize the bucket results of multiple
|
|
|
|
{anomaly-jobs}.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-request]]
|
|
|
|
==== {api-request-title}
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`GET _ml/anomaly_detectors/<job_id>/results/overall_buckets` +
|
2017-10-11 11:24:09 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`GET _ml/anomaly_detectors/<job_id>,<job_id>/results/overall_buckets` +
|
2017-10-11 11:24:09 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`GET _ml/anomaly_detectors/_all/results/overall_buckets`
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[[ml-get-overall-buckets-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
|
2019-10-07 18:23:19 -04:00
|
|
|
privileges. See <<security-privileges>> and <<built-in-roles>>.
|
2019-06-27 16:58:42 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-desc]]
|
|
|
|
==== {api-description-title}
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-30 13:52:23 -04:00
|
|
|
You can summarize the bucket results for all {anomaly-jobs} by using `_all` or
|
|
|
|
by specifying `*` as the `<job_id>`.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-08-02 11:36:39 -04:00
|
|
|
By default, an overall bucket has a span equal to the largest bucket span of the
|
|
|
|
specified {anomaly-jobs}. To override that behavior, use the optional
|
|
|
|
`bucket_span` parameter. To learn more about the concept of buckets, see
|
2019-12-20 13:01:19 -05:00
|
|
|
{ml-docs}/ml-buckets.html[Buckets].
|
2017-10-11 11:24:09 -04:00
|
|
|
|
2019-07-30 13:52:23 -04:00
|
|
|
The `overall_score` is calculated by combining the scores of all the buckets
|
|
|
|
within the overall bucket span. First, the maximum `anomaly_score` per
|
|
|
|
{anomaly-job} in the overall bucket is calculated. Then the `top_n` of those
|
|
|
|
scores are averaged to result in the `overall_score`. This means that you can
|
|
|
|
fine-tune the `overall_score` so that it is more or less sensitive to the number
|
2017-10-11 11:24:09 -04:00
|
|
|
of jobs that detect an anomaly at the same time. For example, if you set `top_n`
|
2019-08-02 11:36:39 -04:00
|
|
|
to `1`, the `overall_score` is the maximum bucket score in the overall bucket.
|
|
|
|
Alternatively, if you set `top_n` to the number of jobs, the `overall_score` is
|
|
|
|
high only when all jobs detect anomalies in that overall bucket. If you set
|
|
|
|
the `bucket_span` parameter (to a value greater than its default), the
|
|
|
|
`overall_score` is the maximum `overall_score` of the overall buckets that have
|
|
|
|
a span equal to the jobs' largest bucket span.
|
2017-10-27 06:14:13 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-path-parms]]
|
|
|
|
==== {api-path-parms-title}
|
2017-10-10 09:41:24 -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-wildcard-list]
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-request-body]]
|
|
|
|
==== {api-request-body-title}
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`allow_no_jobs`::
|
2019-12-27 16:30:26 -05:00
|
|
|
(Optional, boolean)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`bucket_span`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) The span of the overall buckets. Must be greater or equal to
|
|
|
|
the largest bucket span of the specified {anomaly-jobs}, which is the default
|
|
|
|
value.
|
2017-10-27 06:14:13 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`end`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) Returns overall buckets with timestamps earlier than this
|
|
|
|
time.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`exclude_interim`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, boolean)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-interim-results]
|
2019-12-31 16:21:17 -05:00
|
|
|
+
|
|
|
|
--
|
|
|
|
If any of the job bucket results within the overall bucket interval are interim
|
|
|
|
results, the overall bucket results are interim results.
|
|
|
|
--
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`overall_score`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, double) Returns overall buckets with overall scores greater than or
|
|
|
|
equal to this value.
|
2017-10-11 11:24:09 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`start`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) Returns overall buckets with timestamps after this time.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`top_n`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, integer) The number of top {anomaly-job} bucket scores to be used in
|
|
|
|
the `overall_score` calculation. The default value is `1`.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-results]]
|
|
|
|
==== {api-response-body-title}
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
The API returns an array of overall bucket objects, which have the following
|
|
|
|
properties:
|
|
|
|
|
|
|
|
`bucket_span`::
|
|
|
|
(number) The length of the bucket in seconds. Matches the job with the longest `bucket_span` value.
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
`is_interim`::
|
|
|
|
(boolean)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`jobs`::
|
|
|
|
(array) An array of objects that contain the `max_anomaly_score` per `job_id`.
|
|
|
|
|
|
|
|
`overall_score`::
|
|
|
|
(number) The `top_n` average of the maximum bucket `anomaly_score` per job.
|
|
|
|
|
|
|
|
`result_type`::
|
|
|
|
(string) Internal. This is always set to `overall_bucket`.
|
|
|
|
|
|
|
|
`timestamp`::
|
|
|
|
(date)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=timestamp-results]
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-overall-buckets-example]]
|
|
|
|
==== {api-examples-title}
|
2017-10-10 09:41:24 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2017-10-10 09:41:24 -04:00
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
GET _ml/anomaly_detectors/job-*/results/overall_buckets
|
2017-10-10 09:41:24 -04:00
|
|
|
{
|
2017-12-08 11:03:51 -05:00
|
|
|
"overall_score": 80,
|
2017-10-10 09:41:24 -04:00
|
|
|
"start": "1403532000000"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[skip:todo]
|
|
|
|
|
|
|
|
In this example, the API returns a single result that matches the specified
|
2017-12-08 11:03:51 -05:00
|
|
|
score and time constraints. The `overall_score` is the max job score as
|
|
|
|
`top_n` defaults to 1 when not specified:
|
2017-10-10 09:41:24 -04:00
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"count": 1,
|
|
|
|
"overall_buckets": [
|
|
|
|
{
|
|
|
|
"timestamp" : 1403532000000,
|
|
|
|
"bucket_span" : 3600,
|
2017-12-08 11:03:51 -05:00
|
|
|
"overall_score" : 80.0,
|
|
|
|
"jobs" : [
|
|
|
|
{
|
|
|
|
"job_id" : "job-1",
|
|
|
|
"max_anomaly_score" : 30.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"job_id" : "job-2",
|
|
|
|
"max_anomaly_score" : 10.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"job_id" : "job-3",
|
|
|
|
"max_anomaly_score" : 80.0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"is_interim" : false,
|
|
|
|
"result_type" : "overall_bucket"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
The next example is similar but this time `top_n` is set to `2`:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2017-12-08 11:03:51 -05:00
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
GET _ml/anomaly_detectors/job-*/results/overall_buckets
|
2017-12-08 11:03:51 -05:00
|
|
|
{
|
|
|
|
"top_n": 2,
|
|
|
|
"overall_score": 50.0,
|
|
|
|
"start": "1403532000000"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[skip:todo]
|
|
|
|
|
|
|
|
Note how the `overall_score` is now the average of the top 2 job scores:
|
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"count": 1,
|
|
|
|
"overall_buckets": [
|
|
|
|
{
|
|
|
|
"timestamp" : 1403532000000,
|
|
|
|
"bucket_span" : 3600,
|
|
|
|
"overall_score" : 55.0,
|
2017-10-10 09:41:24 -04:00
|
|
|
"jobs" : [
|
|
|
|
{
|
|
|
|
"job_id" : "job-1",
|
|
|
|
"max_anomaly_score" : 30.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"job_id" : "job-2",
|
|
|
|
"max_anomaly_score" : 10.0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"job_id" : "job-3",
|
|
|
|
"max_anomaly_score" : 80.0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"is_interim" : false,
|
|
|
|
"result_type" : "overall_bucket"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
----
|