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-record]]
|
2020-07-20 16:10:54 -04:00
|
|
|
= Get records API
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Get records</titleabbrev>
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-30 13:52:23 -04:00
|
|
|
Retrieves anomaly records for an {anomaly-job}.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-record-request]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {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/records`
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[[ml-get-record-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 `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
|
2020-07-23 19:43:10 -04:00
|
|
|
privileges. See <<security-privileges>>, <<built-in-roles>>, and
|
|
|
|
{ml-docs-setup-privileges}.
|
2019-06-27 16:58:42 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
[[ml-get-record-desc]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-description-title}
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
Records contain the detailed analytical results. They describe the anomalous
|
|
|
|
activity that has been identified in the input data based on the detector
|
|
|
|
configuration.
|
|
|
|
|
|
|
|
There can be many anomaly records depending on the characteristics and size of
|
|
|
|
the input data. In practice, there are often too many to be able to manually
|
|
|
|
process them. The {ml-features} therefore perform a sophisticated aggregation of
|
|
|
|
the anomaly records into buckets.
|
|
|
|
|
|
|
|
The number of record results depends on the number of anomalies found in each
|
|
|
|
bucket, which relates to the number of time series being modeled and the number
|
|
|
|
of detectors.
|
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-record-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-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-record-request-body]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-request-body-title}
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`desc`::
|
2020-10-29 10:05:57 -04:00
|
|
|
(Optional, Boolean)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=desc-results]
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`end`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) Returns records with timestamps earlier than this time.
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`exclude_interim`::
|
2020-10-29 10:05:57 -04:00
|
|
|
(Optional, Boolean)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-interim-results]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`page`.`from`::
|
|
|
|
(Optional, integer) Skips the specified number of records.
|
2017-04-24 13:46:17 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
`page`.`size`::
|
|
|
|
(Optional, integer) Specifies the maximum number of records to obtain.
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`record_score`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, double) Returns records 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
|
|
|
`sort`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) Specifies the sort field for the requested records. By
|
|
|
|
default, the records are sorted by the `anomaly_score` value.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`start`::
|
2019-12-31 16:21:17 -05:00
|
|
|
(Optional, string) Returns records with timestamps after this time.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-record-results]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-response-body-title}
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
The API returns an array of record objects, which have the following properties:
|
|
|
|
|
|
|
|
`actual`::
|
|
|
|
(array) The actual value for the bucket.
|
|
|
|
|
|
|
|
`bucket_span`::
|
|
|
|
(number)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=bucket-span-results]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`by_field_name`::
|
|
|
|
(string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=by-field-name]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`by_field_value`::
|
|
|
|
(string) The value of the by field.
|
|
|
|
|
|
|
|
`causes`::
|
|
|
|
(array) For population analysis, an over field must be specified in the detector.
|
|
|
|
This property contains an array of anomaly records that are the causes for the
|
|
|
|
anomaly that has been identified for the over field. If no over fields exist,
|
|
|
|
this field is not present. This sub-resource contains the most anomalous records
|
|
|
|
for the `over_field_name`. For scalability reasons, a maximum of the 10 most
|
|
|
|
significant causes of the anomaly are returned. As part of the core analytical
|
|
|
|
modeling, these low-level anomaly records are aggregated for their parent over
|
|
|
|
field record. The causes resource contains similar elements to the record
|
|
|
|
resource, namely `actual`, `typical`, `geo_results.actual_point`,
|
|
|
|
`geo_results.typical_point`, `*_field_name` and `*_field_value`. Probability and
|
|
|
|
scores are not applicable to causes.
|
|
|
|
|
|
|
|
`detector_index`::
|
|
|
|
(number)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=detector-index]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`field_name`::
|
|
|
|
(string) Certain functions require a field to operate on, for example, `sum()`.
|
|
|
|
For those functions, this value is the name of the field to be analyzed.
|
|
|
|
|
|
|
|
`function`::
|
|
|
|
(string) The function in which the anomaly occurs, as specified in the
|
|
|
|
detector configuration. For example, `max`.
|
|
|
|
|
|
|
|
`function_description`::
|
|
|
|
(string) The description of the function in which the anomaly occurs, as
|
|
|
|
specified in the detector configuration.
|
|
|
|
|
|
|
|
`geo_results.actual_point`::
|
|
|
|
(string) The actual value for the bucket formatted as a `geo_point`. If the
|
|
|
|
detector function is `lat_long`, this is a comma delimited string of the
|
|
|
|
latitude and longitude.
|
|
|
|
|
|
|
|
`geo_results.typical_point`::
|
|
|
|
(string) The typical value for the bucket formatted as a `geo_point`. If the
|
|
|
|
detector function is `lat_long`, this is a comma delimited string of the
|
|
|
|
latitude and longitude.
|
|
|
|
|
|
|
|
`influencers`::
|
|
|
|
(array) If `influencers` was specified in the detector configuration, this array
|
|
|
|
contains influencers that contributed to or were to blame for an anomaly.
|
|
|
|
|
|
|
|
`initial_record_score`::
|
|
|
|
(number) A normalized score between 0-100, which is based on the probability of
|
|
|
|
the anomalousness of this record. This is the initial value that was calculated
|
|
|
|
at the time the bucket was processed.
|
|
|
|
|
|
|
|
`is_interim`::
|
2020-10-29 10:05:57 -04:00
|
|
|
(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
|
|
|
|
|
|
|
`job_id`::
|
|
|
|
(string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`over_field_name`::
|
|
|
|
(string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=over-field-name]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`over_field_value`::
|
|
|
|
(string) The value of the over field.
|
|
|
|
|
|
|
|
`partition_field_name`::
|
|
|
|
(string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=partition-field-name]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`partition_field_value`::
|
|
|
|
(string) The value of the partition field.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-12-31 16:21:17 -05:00
|
|
|
`probability`::
|
|
|
|
(number) The probability of the individual anomaly occurring, in the range `0`
|
|
|
|
to `1`. This value can be held to a high precision of over 300 decimal places,
|
|
|
|
so the `record_score` is provided as a human-readable and friendly
|
|
|
|
interpretation of this.
|
|
|
|
|
|
|
|
`multi_bucket_impact`::
|
|
|
|
(number) an indication of how strongly an anomaly is multi bucket or single
|
|
|
|
bucket. The value is on a scale of `-5.0` to `+5.0` where `-5.0` means the
|
|
|
|
anomaly is purely single bucket and `+5.0` means the anomaly is purely multi
|
|
|
|
bucket.
|
|
|
|
|
|
|
|
`record_score`::
|
|
|
|
(number) A normalized score between 0-100, which is based on the probability of
|
|
|
|
the anomalousness of this record. Unlike `initial_record_score`, this value will
|
|
|
|
be updated by a re-normalization process as new data is analyzed.
|
|
|
|
|
|
|
|
`result_type`::
|
|
|
|
(string) Internal. This is always set to `record`.
|
|
|
|
|
|
|
|
`timestamp`::
|
|
|
|
(date)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=timestamp-results]
|
2019-12-31 16:21:17 -05:00
|
|
|
|
|
|
|
`typical`::
|
|
|
|
(array) The typical value for the bucket, according to analytical modeling.
|
|
|
|
|
|
|
|
NOTE: Additional record properties are added, depending on the fields being
|
|
|
|
analyzed. For example, if it's analyzing `hostname` as a _by field_, then a field
|
|
|
|
`hostname` is added to the result document. This information enables you to
|
|
|
|
filter the anomaly results more easily.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-get-record-example]]
|
2020-07-20 16:10:54 -04:00
|
|
|
== {api-examples-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2017-04-10 19:14:26 -04:00
|
|
|
--------------------------------------------------
|
2019-12-31 16:21:17 -05:00
|
|
|
GET _ml/anomaly_detectors/low_request_rate/results/records
|
2017-04-10 19:14:26 -04:00
|
|
|
{
|
|
|
|
"sort": "record_score",
|
|
|
|
"desc": true,
|
2017-04-11 21:52:47 -04:00
|
|
|
"start": "1454944100000"
|
2017-04-10 19:14:26 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2019-12-31 16:21:17 -05:00
|
|
|
// TEST[skip:Kibana sample data]
|
2017-04-10 19:14:26 -04:00
|
|
|
|
2017-04-11 21:52:47 -04:00
|
|
|
In this example, the API returns twelve results for the specified
|
|
|
|
time constraints:
|
2017-04-21 11:23:27 -04:00
|
|
|
[source,js]
|
2017-04-04 18:26:39 -04:00
|
|
|
----
|
|
|
|
{
|
2019-12-31 16:21:17 -05:00
|
|
|
"count" : 4,
|
|
|
|
"records" : [
|
2017-04-10 19:14:26 -04:00
|
|
|
{
|
2019-12-31 16:21:17 -05:00
|
|
|
"job_id" : "low_request_rate",
|
|
|
|
"result_type" : "record",
|
|
|
|
"probability" : 1.3882308899968812E-4,
|
|
|
|
"multi_bucket_impact" : -5.0,
|
|
|
|
"record_score" : 94.98554565630553,
|
|
|
|
"initial_record_score" : 94.98554565630553,
|
|
|
|
"bucket_span" : 3600,
|
|
|
|
"detector_index" : 0,
|
|
|
|
"is_interim" : false,
|
|
|
|
"timestamp" : 1577793600000,
|
|
|
|
"function" : "low_count",
|
|
|
|
"function_description" : "count",
|
|
|
|
"typical" : [
|
|
|
|
28.254208230188834
|
2017-04-10 19:14:26 -04:00
|
|
|
],
|
2019-12-31 16:21:17 -05:00
|
|
|
"actual" : [
|
|
|
|
0.0
|
|
|
|
]
|
2017-04-10 19:14:26 -04:00
|
|
|
},
|
|
|
|
...
|
2017-04-04 18:26:39 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
----
|