get-bucket.asciidoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. [role="xpack"]
  2. [[ml-get-bucket]]
  3. = Get buckets API
  4. ++++
  5. <titleabbrev>Get buckets</titleabbrev>
  6. ++++
  7. Retrieves {anomaly-job} results for one or more buckets.
  8. [[ml-get-bucket-request]]
  9. == {api-request-title}
  10. `GET _ml/anomaly_detectors/<job_id>/results/buckets` +
  11. `GET _ml/anomaly_detectors/<job_id>/results/buckets/<timestamp>`
  12. [[ml-get-bucket-prereqs]]
  13. == {api-prereq-title}
  14. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  15. `machine_learning_user` built-in role.
  16. [[ml-get-bucket-desc]]
  17. == {api-description-title}
  18. The get buckets API presents a chronological view of the records, grouped by
  19. bucket.
  20. [[ml-get-bucket-path-parms]]
  21. == {api-path-parms-title}
  22. `<job_id>`::
  23. (Required, string)
  24. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  25. `<timestamp>`::
  26. (Optional, string) The timestamp of a single bucket result. If you do not
  27. specify this parameter, the API returns information about all buckets.
  28. [[ml-get-bucket-query-parms]]
  29. == {api-query-parms-title}
  30. `anomaly_score`::
  31. (Optional, double) Returns buckets with anomaly scores greater or equal than
  32. this value. Defaults to `0.0`.
  33. `desc`::
  34. (Optional, Boolean) If true, the buckets are sorted in descending order.
  35. Defaults to `false`.
  36. `end`::
  37. (Optional, string) Returns buckets with timestamps earlier than this time.
  38. Defaults to `-1`, which means it is unset and results are not limited to
  39. specific timestamps.
  40. `exclude_interim`::
  41. (Optional, Boolean)
  42. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-interim-results]
  43. `expand`::
  44. (Optional, Boolean) If true, the output includes anomaly records. Defaults to `false`.
  45. `from`::
  46. (Optional, integer) Skips the specified number of buckets. Defaults to `0`.
  47. `size`::
  48. (Optional, integer) Specifies the maximum number of buckets to obtain. Defaults
  49. to `100`.
  50. `sort`::
  51. (Optional, string) Specifies the sort field for the requested buckets. By
  52. default, the buckets are sorted by the `timestamp` field.
  53. `start`::
  54. (Optional, string) Returns buckets with timestamps after this time. Defaults to
  55. `-1`, which means it is unset and results are not limited to specific
  56. timestamps.
  57. [[ml-get-bucket-request-body]]
  58. == {api-request-body-title}
  59. You can also specify the query parameters in the request body; the exception are
  60. `from` and `size`, use `page` instead:
  61. `page`::
  62. +
  63. .Properties of `page`
  64. [%collapsible%open]
  65. ====
  66. `from`:::
  67. (Optional, integer) Skips the specified number of buckets. Defaults to `0`.
  68. `size`:::
  69. (Optional, integer) Specifies the maximum number of buckets to obtain. Defaults
  70. to `100`.
  71. ====
  72. [role="child_attributes"]
  73. [[ml-get-bucket-results]]
  74. == {api-response-body-title}
  75. The API returns an array of bucket objects, which have the following properties:
  76. `anomaly_score`::
  77. (number) The maximum anomaly score, between 0-100, for any of the bucket
  78. influencers. This is an overall, rate-limited score for the job. All the anomaly
  79. records in the bucket contribute to this score. This value might be updated as
  80. new data is analyzed.
  81. `bucket_influencers`::
  82. (array) An array of bucket influencer objects.
  83. +
  84. .Properties of `bucket_influencers`
  85. [%collapsible%open]
  86. ====
  87. `anomaly_score`:::
  88. (number) A normalized score between 0-100, which is calculated for each bucket
  89. influencer. This score might be updated as newer data is analyzed.
  90. `bucket_span`:::
  91. (number) The length of the bucket in seconds. This value matches the
  92. `bucket_span` that is specified in the job.
  93. `influencer_field_name`:::
  94. (string) The field name of the influencer.
  95. ////
  96. `influencer_field_value`:::
  97. (string) The field value of the influencer.
  98. ////
  99. `initial_anomaly_score`:::
  100. (number) The score between 0-100 for each bucket influencer. This score is the
  101. initial value that was calculated at the time the bucket was processed.
  102. `is_interim`:::
  103. (Boolean)
  104. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  105. `job_id`:::
  106. (string)
  107. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  108. `probability`:::
  109. (number) The probability that the bucket has this behavior, in the range 0 to 1.
  110. This value can be held to a high precision of over 300 decimal places, so the
  111. `anomaly_score` is provided as a human-readable and friendly interpretation of
  112. this.
  113. `raw_anomaly_score`:::
  114. (number) Internal.
  115. `result_type`:::
  116. (string) Internal. This value is always set to `bucket_influencer`.
  117. `timestamp`:::
  118. (date) The start time of the bucket for which these results were calculated.
  119. ====
  120. `bucket_span`::
  121. (number)
  122. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=bucket-span-results]
  123. `event_count`::
  124. (number) The number of input data records processed in this bucket.
  125. `initial_anomaly_score`::
  126. (number) The maximum `anomaly_score` for any of the bucket influencers. This is
  127. the initial value that was calculated at the time the bucket was processed.
  128. `is_interim`::
  129. (Boolean)
  130. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  131. `job_id`::
  132. (string)
  133. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  134. `processing_time_ms`::
  135. (number) The amount of time, in milliseconds, that it took to analyze the
  136. bucket contents and calculate results.
  137. `result_type`::
  138. (string) Internal. This value is always set to `bucket`.
  139. `timestamp`::
  140. (date) The start time of the bucket. This timestamp uniquely identifies the
  141. bucket.
  142. +
  143. --
  144. NOTE: Events that occur exactly at the timestamp of the bucket are included in
  145. the results for the bucket.
  146. --
  147. [[ml-get-bucket-example]]
  148. == {api-examples-title}
  149. [source,console]
  150. --------------------------------------------------
  151. GET _ml/anomaly_detectors/low_request_rate/results/buckets
  152. {
  153. "anomaly_score": 80,
  154. "start": "1454530200001"
  155. }
  156. --------------------------------------------------
  157. // TEST[skip:Kibana sample data]
  158. In this example, the API returns a single result that matches the specified
  159. score and time constraints:
  160. [source,js]
  161. ----
  162. {
  163. "count" : 1,
  164. "buckets" : [
  165. {
  166. "job_id" : "low_request_rate",
  167. "timestamp" : 1578398400000,
  168. "anomaly_score" : 91.58505459594764,
  169. "bucket_span" : 3600,
  170. "initial_anomaly_score" : 91.58505459594764,
  171. "event_count" : 0,
  172. "is_interim" : false,
  173. "bucket_influencers" : [
  174. {
  175. "job_id" : "low_request_rate",
  176. "result_type" : "bucket_influencer",
  177. "influencer_field_name" : "bucket_time",
  178. "initial_anomaly_score" : 91.58505459594764,
  179. "anomaly_score" : 91.58505459594764,
  180. "raw_anomaly_score" : 0.5758246639716365,
  181. "probability" : 1.7340849573442696E-4,
  182. "timestamp" : 1578398400000,
  183. "bucket_span" : 3600,
  184. "is_interim" : false
  185. }
  186. ],
  187. "processing_time_ms" : 0,
  188. "result_type" : "bucket"
  189. }
  190. ]
  191. }
  192. ----