get-bucket.asciidoc 6.2 KB

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