get-record.asciidoc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. //Begin anomaly_score_explanation
  79. `anomaly_score_explanation`::
  80. (object) When present, it provides information about the factors impacting the
  81. initial anomaly score.
  82. +
  83. .Properties of `anomaly_score_explanation`
  84. [%collapsible%open]
  85. ====
  86. `anomaly_characteristics_impact`::::
  87. (Optional, integer) Impact of the statistical properties of the detected anomalous interval.
  88. `anomaly_length`::::
  89. (Optional, integer) Length of the detected anomaly in the number of buckets.
  90. `anomaly_type`::::
  91. (Optional, string) Type of the detected anomaly: spike or dip.
  92. `high_variance_penalty`::::
  93. (Optional, boolean) Indicates reduction of anomaly score for the bucket with large confidence intervals.
  94. `incomplete_bucket_penalty`::::
  95. (Optional, boolean) Indicates reduction of anomaly score if the bucket contains fewer samples than historically expected.
  96. `lower_confidence_bound`::::
  97. (Optional, double) Lower bound of the 95% confidence interval.
  98. `multi_bucket_impact`::::
  99. (Optional, integer) Impact of the deviation between actual and typical in the past 12 buckets."
  100. `single_bucket_impact`::::
  101. (Optional, integer) Impact of the deviation between actual and typical in the current bucket.
  102. `typical_value`::::
  103. (Optional, double) Typical (expected) value for this bucket.
  104. `upper_confidence_bound`::::
  105. (Optional, double) Upper bound of the 95% confidence interval.
  106. ====
  107. //End anomaly_score_explanation
  108. `bucket_span`::
  109. (number)
  110. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=bucket-span-results]
  111. `by_field_name`::
  112. (string)
  113. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=by-field-name]
  114. `by_field_value`::
  115. (string) The value of `by_field_name`.
  116. `causes`::
  117. (array) For population analysis, an over field must be specified in the detector.
  118. This property contains an array of anomaly records that are the causes for the
  119. anomaly that has been identified for the over field. If no over fields exist,
  120. this field is not present. This sub-resource contains the most anomalous records
  121. for the `over_field_name`. For scalability reasons, a maximum of the 10 most
  122. 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
  123. field record. The causes resource contains similar elements to the record
  124. resource, namely `actual`, `typical`, `geo_results.actual_point`,
  125. `geo_results.typical_point`, `*_field_name` and `*_field_value`. Probability and
  126. scores are not applicable to causes.
  127. `detector_index`::
  128. (number) A unique identifier for the detector.
  129. `field_name`::
  130. (string) Certain functions require a field to operate on, for example, `sum()`.
  131. For those functions, this value is the name of the field to be analyzed.
  132. `function`::
  133. (string) The function in which the anomaly occurs, as specified in the detector
  134. configuration. For example, `max`.
  135. `function_description`::
  136. (string) The description of the function in which the anomaly occurs, as
  137. specified in the detector configuration.
  138. `geo_results.actual_point`::
  139. (string) The actual value for the bucket formatted as a `geo_point`. If the
  140. detector function is `lat_long`, this is a comma delimited string of the
  141. latitude and longitude.
  142. `geo_results.typical_point`::
  143. (string) The typical value for the bucket formatted as a `geo_point`. If the
  144. detector function is `lat_long`, this is a comma delimited string of the
  145. latitude and longitude.
  146. `influencers`::
  147. (array) If `influencers` was specified in the detector configuration, this array
  148. contains influencers that contributed to or were to blame for an anomaly.
  149. `initial_record_score`::
  150. (number) A normalized score between 0-100, which is based on the probability of
  151. the anomalousness of this record. This is the initial value that was calculated
  152. at the time the bucket was processed.
  153. `is_interim`::
  154. (Boolean)
  155. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  156. `job_id`::
  157. (string)
  158. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  159. `over_field_name`::
  160. (string)
  161. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=over-field-name]
  162. `over_field_value`::
  163. (string) The value of `over_field_name`.
  164. `partition_field_name`::
  165. (string)
  166. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=partition-field-name]
  167. `partition_field_value`::
  168. (string) The value of `partition_field_name`.
  169. `probability`::
  170. (number) The probability of the individual anomaly occurring, in the range
  171. 0 to 1. For example, 0.0000772031. This value can be held to a high precision
  172. of over 300 decimal places, so the `record_score` is provided as a
  173. human-readable and friendly interpretation of this.
  174. `multi_bucket_impact`::
  175. (number) An indication of how strongly an anomaly is multi bucket or single
  176. bucket. The value is on a scale of `-5.0` to `+5.0` where `-5.0` means the
  177. anomaly is purely single bucket and `+5.0` means the anomaly is purely multi
  178. bucket.
  179. `record_score`::
  180. (number) A normalized score between 0-100, which is based on the probability of
  181. the anomalousness of this record. Unlike `initial_record_score`, this value will
  182. be updated by a re-normalization process as new data is analyzed.
  183. `result_type`::
  184. (string) Internal. This is always set to `record`.
  185. `timestamp`::
  186. (date)
  187. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=timestamp-results]
  188. `typical`::
  189. (array) The typical value for the bucket, according to analytical modeling.
  190. NOTE: Additional record properties are added, depending on the fields being
  191. analyzed. For example, if it's analyzing `hostname` as a _by field_, then a field
  192. `hostname` is added to the result document. This information enables you to
  193. filter the anomaly results more easily.
  194. [[ml-get-record-example]]
  195. == {api-examples-title}
  196. [source,console]
  197. --------------------------------------------------
  198. GET _ml/anomaly_detectors/low_request_rate/results/records
  199. {
  200. "sort": "record_score",
  201. "desc": true,
  202. "start": "1454944100000"
  203. }
  204. --------------------------------------------------
  205. // TEST[skip:Kibana sample data]
  206. [source,js]
  207. ----
  208. {
  209. "count" : 4,
  210. "records" : [
  211. {
  212. "job_id" : "low_request_rate",
  213. "result_type" : "record",
  214. "probability" : 1.3882308899968812E-4,
  215. "multi_bucket_impact" : -5.0,
  216. "record_score" : 94.98554565630553,
  217. "initial_record_score" : 94.98554565630553,
  218. "bucket_span" : 3600,
  219. "detector_index" : 0,
  220. "is_interim" : false,
  221. "timestamp" : 1577793600000,
  222. "function" : "low_count",
  223. "function_description" : "count",
  224. "typical" : [
  225. 28.254208230188834
  226. ],
  227. "actual" : [
  228. 0.0
  229. ]
  230. },
  231. ...
  232. ]
  233. }
  234. ----