get-bucket.asciidoc 6.3 KB

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