1
0

get-bucket.asciidoc 5.9 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. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  16. `machine_learning_user` built-in role.
  17. [[ml-get-bucket-desc]]
  18. == {api-description-title}
  19. The get buckets API presents a chronological view of the records, grouped by
  20. bucket.
  21. [[ml-get-bucket-path-parms]]
  22. == {api-path-parms-title}
  23. `<job_id>`::
  24. (Required, string)
  25. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  26. `<timestamp>`::
  27. (Optional, string) The timestamp of a single bucket result. If you do not
  28. specify this parameter, the API returns information about all buckets.
  29. [[ml-get-bucket-request-body]]
  30. == {api-request-body-title}
  31. `anomaly_score`::
  32. (Optional, double) Returns buckets with anomaly scores greater or equal than
  33. this value.
  34. `desc`::
  35. (Optional, Boolean) If true, the buckets are sorted in descending order.
  36. `end`::
  37. (Optional, string) Returns buckets with timestamps earlier than this time.
  38. `exclude_interim`::
  39. (Optional, Boolean)
  40. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-interim-results]
  41. `expand`::
  42. (Optional, Boolean) If true, the output includes anomaly records.
  43. `page`.`from`::
  44. (Optional, integer) Skips the specified number of buckets.
  45. `page`.`size`::
  46. (Optional, integer) Specifies the maximum number of buckets to obtain.
  47. `sort`::
  48. (Optional, string) Specifies the sort field for the requested buckets. By
  49. default, the buckets are sorted by the `timestamp` field.
  50. `start`::
  51. (Optional, string) Returns buckets with timestamps after this time.
  52. [role="child_attributes"]
  53. [[ml-get-bucket-results]]
  54. == {api-response-body-title}
  55. The API returns an array of bucket objects, which have the following properties:
  56. `anomaly_score`::
  57. (number) The maximum anomaly score, between 0-100, for any of the bucket
  58. influencers. This is an overall, rate-limited score for the job. All the anomaly
  59. records in the bucket contribute to this score. This value might be updated as
  60. new data is analyzed.
  61. `bucket_influencers`::
  62. (array) An array of bucket influencer objects.
  63. +
  64. .Properties of `bucket_influencers`
  65. [%collapsible%open]
  66. ====
  67. `anomaly_score`:::
  68. (number) A normalized score between 0-100, which is calculated for each bucket
  69. influencer. This score might be updated as newer data is analyzed.
  70. `bucket_span`:::
  71. (number) The length of the bucket in seconds. This value matches the
  72. `bucket_span` that is specified in the job.
  73. `initial_anomaly_score`:::
  74. (number) The score between 0-100 for each bucket influencer. This score is the
  75. initial value that was calculated at the time the bucket was processed.
  76. `influencer_field_name`:::
  77. (string) The field name of the influencer.
  78. `influencer_field_value`:::
  79. (string) The field value of the influencer.
  80. `is_interim`:::
  81. (Boolean)
  82. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  83. `job_id`:::
  84. (string)
  85. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  86. `probability`:::
  87. (number) The probability that the bucket has this behavior, in the range 0 to 1.
  88. This value can be held to a high precision of over 300 decimal places, so the
  89. `anomaly_score` is provided as a human-readable and friendly interpretation of
  90. this.
  91. `raw_anomaly_score`:::
  92. (number) Internal.
  93. `result_type`:::
  94. (string) Internal. This value is always set to `bucket_influencer`.
  95. `timestamp`:::
  96. (date) The start time of the bucket for which these results were calculated.
  97. ====
  98. `bucket_span`::
  99. (number)
  100. include::{es-repo-dir}/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::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  109. `job_id`::
  110. (string)
  111. include::{es-repo-dir}/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. ----