get-bucket.asciidoc 6.2 KB

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