get-record.asciidoc 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. [role="xpack"]
  2. [[ml-get-record]]
  3. = Get records API
  4. ++++
  5. <titleabbrev>Get records</titleabbrev>
  6. ++++
  7. Retrieves anomaly records for an {anomaly-job}.
  8. [[ml-get-record-request]]
  9. == {api-request-title}
  10. `GET _ml/anomaly_detectors/<job_id>/results/records`
  11. [[ml-get-record-prereqs]]
  12. == {api-prereq-title}
  13. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  14. `machine_learning_user` built-in role.
  15. [[ml-get-record-desc]]
  16. == {api-description-title}
  17. Records contain the detailed analytical results. They describe the anomalous
  18. activity that has been identified in the input data based on the detector
  19. configuration.
  20. There can be many anomaly records depending on the characteristics and size of
  21. the input data. In practice, there are often too many to be able to manually
  22. process them. The {ml-features} therefore perform a sophisticated aggregation of
  23. the anomaly records into buckets.
  24. The number of record results depends on the number of anomalies found in each
  25. bucket, which relates to the number of time series being modeled and the number
  26. of detectors.
  27. [[ml-get-record-path-parms]]
  28. == {api-path-parms-title}
  29. `<job_id>`::
  30. (Required, string)
  31. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  32. [[ml-get-record-query-parms]]
  33. == {api-query-parms-title}
  34. `desc`::
  35. (Optional, Boolean)
  36. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=desc-results]
  37. `end`::
  38. (Optional, string) Returns records with timestamps earlier than this time.
  39. Defaults to `-1`, which means it is unset and results are not limited to
  40. specific timestamps.
  41. `exclude_interim`::
  42. (Optional, Boolean)
  43. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-interim-results]
  44. `from`::
  45. (Optional, integer) Skips the specified number of records. Defaults to `0`.
  46. `record_score`::
  47. (Optional, double) Returns records with anomaly scores greater or equal than
  48. this value. Defaults to `0.0`.
  49. `size`::
  50. (Optional, integer) Specifies the maximum number of records to obtain. Defaults
  51. to `100`.
  52. `sort`::
  53. (Optional, string) Specifies the sort field for the requested records. By
  54. default, the records are sorted by the `record_score` value.
  55. `start`::
  56. (Optional, string) Returns records with timestamps after this time. Defaults to
  57. `-1`, which means it is unset and results are not limited to specific timestamps.
  58. [[ml-get-record-request-body]]
  59. == {api-request-body-title}
  60. You can also specify the query parameters in the request body; the exception are
  61. `from` and `size`, use `page` instead:
  62. `page`::
  63. +
  64. .Properties of `page`
  65. [%collapsible%open]
  66. ====
  67. `from`:::
  68. (Optional, integer) Skips the specified number of records. Defaults to `0`.
  69. `size`:::
  70. (Optional, integer) Specifies the maximum number of records to obtain. Defaults
  71. to `100`.
  72. ====
  73. [[ml-get-record-results]]
  74. == {api-response-body-title}
  75. The API returns an array of record objects, which have the following properties:
  76. `actual`::
  77. (array) The actual value for the bucket.
  78. `bucket_span`::
  79. (number)
  80. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=bucket-span-results]
  81. `by_field_name`::
  82. (string)
  83. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=by-field-name]
  84. `by_field_value`::
  85. (string) The value of `by_field_name`.
  86. `causes`::
  87. (array) For population analysis, an over field must be specified in the detector.
  88. This property contains an array of anomaly records that are the causes for the
  89. anomaly that has been identified for the over field. If no over fields exist,
  90. this field is not present. This sub-resource contains the most anomalous records
  91. for the `over_field_name`. For scalability reasons, a maximum of the 10 most
  92. 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
  93. field record. The causes resource contains similar elements to the record
  94. resource, namely `actual`, `typical`, `geo_results.actual_point`,
  95. `geo_results.typical_point`, `*_field_name` and `*_field_value`. Probability and
  96. scores are not applicable to causes.
  97. `detector_index`::
  98. (number) A unique identifier for the detector.
  99. `field_name`::
  100. (string) Certain functions require a field to operate on, for example, `sum()`.
  101. For those functions, this value is the name of the field to be analyzed.
  102. `function`::
  103. (string) The function in which the anomaly occurs, as specified in the detector
  104. configuration. For example, `max`.
  105. `function_description`::
  106. (string) The description of the function in which the anomaly occurs, as
  107. specified in the detector configuration.
  108. `geo_results.actual_point`::
  109. (string) The actual value for the bucket formatted as a `geo_point`. If the
  110. detector function is `lat_long`, this is a comma delimited string of the
  111. latitude and longitude.
  112. `geo_results.typical_point`::
  113. (string) The typical value for the bucket formatted as a `geo_point`. If the
  114. detector function is `lat_long`, this is a comma delimited string of the
  115. latitude and longitude.
  116. `influencers`::
  117. (array) If `influencers` was specified in the detector configuration, this array
  118. contains influencers that contributed to or were to blame for an anomaly.
  119. `initial_record_score`::
  120. (number) A normalized score between 0-100, which is based on the probability of
  121. the anomalousness of this record. This is the initial value that was calculated
  122. at the time the bucket was processed.
  123. `is_interim`::
  124. (Boolean)
  125. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  126. `job_id`::
  127. (string)
  128. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  129. `over_field_name`::
  130. (string)
  131. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=over-field-name]
  132. `over_field_value`::
  133. (string) The value of `over_field_name`.
  134. `partition_field_name`::
  135. (string)
  136. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=partition-field-name]
  137. `partition_field_value`::
  138. (string) The value of `partition_field_name`.
  139. `probability`::
  140. (number) The probability of the individual anomaly occurring, in the range
  141. 0 to 1. For example, 0.0000772031. This value can be held to a high precision
  142. of over 300 decimal places, so the `record_score` is provided as a
  143. human-readable and friendly interpretation of this.
  144. `multi_bucket_impact`::
  145. (number) An indication of how strongly an anomaly is multi bucket or single
  146. bucket. The value is on a scale of `-5.0` to `+5.0` where `-5.0` means the
  147. anomaly is purely single bucket and `+5.0` means the anomaly is purely multi
  148. bucket.
  149. `record_score`::
  150. (number) A normalized score between 0-100, which is based on the probability of
  151. the anomalousness of this record. Unlike `initial_record_score`, this value will
  152. be updated by a re-normalization process as new data is analyzed.
  153. `result_type`::
  154. (string) Internal. This is always set to `record`.
  155. `timestamp`::
  156. (date)
  157. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=timestamp-results]
  158. `typical`::
  159. (array) The typical value for the bucket, according to analytical modeling.
  160. NOTE: Additional record properties are added, depending on the fields being
  161. analyzed. For example, if it's analyzing `hostname` as a _by field_, then a field
  162. `hostname` is added to the result document. This information enables you to
  163. filter the anomaly results more easily.
  164. [[ml-get-record-example]]
  165. == {api-examples-title}
  166. [source,console]
  167. --------------------------------------------------
  168. GET _ml/anomaly_detectors/low_request_rate/results/records
  169. {
  170. "sort": "record_score",
  171. "desc": true,
  172. "start": "1454944100000"
  173. }
  174. --------------------------------------------------
  175. // TEST[skip:Kibana sample data]
  176. [source,js]
  177. ----
  178. {
  179. "count" : 4,
  180. "records" : [
  181. {
  182. "job_id" : "low_request_rate",
  183. "result_type" : "record",
  184. "probability" : 1.3882308899968812E-4,
  185. "multi_bucket_impact" : -5.0,
  186. "record_score" : 94.98554565630553,
  187. "initial_record_score" : 94.98554565630553,
  188. "bucket_span" : 3600,
  189. "detector_index" : 0,
  190. "is_interim" : false,
  191. "timestamp" : 1577793600000,
  192. "function" : "low_count",
  193. "function_description" : "count",
  194. "typical" : [
  195. 28.254208230188834
  196. ],
  197. "actual" : [
  198. 0.0
  199. ]
  200. },
  201. ...
  202. ]
  203. }
  204. ----