get-bucket.asciidoc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. [role="child_attributes"]
  58. [[ml-get-bucket-results]]
  59. ==== {api-response-body-title}
  60. The API returns an array of bucket objects, which have the following properties:
  61. `anomaly_score`::
  62. (number) The maximum anomaly score, between 0-100, for any of the bucket
  63. influencers. This is an overall, rate-limited score for the job. All the anomaly
  64. records in the bucket contribute to this score. This value might be updated as
  65. new data is analyzed.
  66. `bucket_influencers`::
  67. (array) An array of bucket influencer objects.
  68. +
  69. .Properties of `bucket_influencers`
  70. [%collapsible%open]
  71. ====
  72. `anomaly_score`:::
  73. (number) A normalized score between 0-100, which is calculated for each bucket
  74. influencer. This score might be updated as newer data is analyzed.
  75. `bucket_span`:::
  76. (number) The length of the bucket in seconds. This value matches the
  77. `bucket_span` that is specified in the job.
  78. `initial_anomaly_score`:::
  79. (number) The score between 0-100 for each bucket influencer. This score is the
  80. initial value that was calculated at the time the bucket was processed.
  81. `influencer_field_name`:::
  82. (string) The field name of the influencer.
  83. `influencer_field_value`:::
  84. (string) The field value of the influencer.
  85. `is_interim`:::
  86. (boolean)
  87. include::{docdir}/ml/ml-shared.asciidoc[tag=is-interim]
  88. `job_id`:::
  89. (string)
  90. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  91. `probability`:::
  92. (number) The probability that the bucket has this behavior, in the range 0 to 1.
  93. This value can be held to a high precision of over 300 decimal places, so the
  94. `anomaly_score` is provided as a human-readable and friendly interpretation of
  95. this.
  96. `raw_anomaly_score`:::
  97. (number) Internal.
  98. `result_type`:::
  99. (string) Internal. This value is always set to `bucket_influencer`.
  100. `timestamp`:::
  101. (date) The start time of the bucket for which these results were calculated.
  102. ====
  103. `bucket_span`::
  104. (number)
  105. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-span-results]
  106. `event_count`::
  107. (number) The number of input data records processed in this bucket.
  108. `initial_anomaly_score`::
  109. (number) The maximum `anomaly_score` for any of the bucket influencers. This is
  110. the initial value that was calculated at the time the bucket was processed.
  111. `is_interim`::
  112. (boolean)
  113. include::{docdir}/ml/ml-shared.asciidoc[tag=is-interim]
  114. `job_id`::
  115. (string)
  116. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  117. `processing_time_ms`::
  118. (number) The amount of time, in milliseconds, that it took to analyze the
  119. bucket contents and calculate results.
  120. `result_type`::
  121. (string) Internal. This value is always set to `bucket`.
  122. `timestamp`::
  123. (date) The start time of the bucket. This timestamp uniquely identifies the
  124. bucket.
  125. +
  126. --
  127. NOTE: Events that occur exactly at the timestamp of the bucket are included in
  128. the results for the bucket.
  129. --
  130. [[ml-get-bucket-example]]
  131. ==== {api-examples-title}
  132. [source,console]
  133. --------------------------------------------------
  134. GET _ml/anomaly_detectors/low_request_rate/results/buckets
  135. {
  136. "anomaly_score": 80,
  137. "start": "1454530200001"
  138. }
  139. --------------------------------------------------
  140. // TEST[skip:Kibana sample data]
  141. In this example, the API returns a single result that matches the specified
  142. score and time constraints:
  143. [source,js]
  144. ----
  145. {
  146. "count" : 1,
  147. "buckets" : [
  148. {
  149. "job_id" : "low_request_rate",
  150. "timestamp" : 1578398400000,
  151. "anomaly_score" : 91.58505459594764,
  152. "bucket_span" : 3600,
  153. "initial_anomaly_score" : 91.58505459594764,
  154. "event_count" : 0,
  155. "is_interim" : false,
  156. "bucket_influencers" : [
  157. {
  158. "job_id" : "low_request_rate",
  159. "result_type" : "bucket_influencer",
  160. "influencer_field_name" : "bucket_time",
  161. "initial_anomaly_score" : 91.58505459594764,
  162. "anomaly_score" : 91.58505459594764,
  163. "raw_anomaly_score" : 0.5758246639716365,
  164. "probability" : 1.7340849573442696E-4,
  165. "timestamp" : 1578398400000,
  166. "bucket_span" : 3600,
  167. "is_interim" : false
  168. }
  169. ],
  170. "processing_time_ms" : 0,
  171. "result_type" : "bucket"
  172. }
  173. ]
  174. }
  175. ----