get-overall-buckets.asciidoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. [role="xpack"]
  2. [[ml-get-overall-buckets]]
  3. = Get overall buckets API
  4. ++++
  5. <titleabbrev>Get overall buckets</titleabbrev>
  6. ++++
  7. Retrieves overall bucket results that summarize the bucket results of multiple
  8. {anomaly-jobs}.
  9. [[ml-get-overall-buckets-request]]
  10. == {api-request-title}
  11. `GET _ml/anomaly_detectors/<job_id>/results/overall_buckets` +
  12. `GET _ml/anomaly_detectors/<job_id>,<job_id>/results/overall_buckets` +
  13. `GET _ml/anomaly_detectors/_all/results/overall_buckets`
  14. [[ml-get-overall-buckets-prereqs]]
  15. == {api-prereq-title}
  16. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  17. `machine_learning_user` built-in role.
  18. [[ml-get-overall-buckets-desc]]
  19. == {api-description-title}
  20. By default, an overall bucket has a span equal to the largest bucket span of the
  21. specified {anomaly-jobs}. To override that behavior, use the optional
  22. `bucket_span` parameter. To learn more about the concept of buckets, see
  23. {ml-docs}/ml-buckets.html[Buckets].
  24. The `overall_score` is calculated by combining the scores of all the buckets
  25. within the overall bucket span. First, the maximum `anomaly_score` per
  26. {anomaly-job} in the overall bucket is calculated. Then the `top_n` of those
  27. scores are averaged to result in the `overall_score`. This means that you can
  28. fine-tune the `overall_score` so that it is more or less sensitive to the number
  29. of jobs that detect an anomaly at the same time. For example, if you set `top_n`
  30. to `1`, the `overall_score` is the maximum bucket score in the overall bucket.
  31. Alternatively, if you set `top_n` to the number of jobs, the `overall_score` is
  32. high only when all jobs detect anomalies in that overall bucket. If you set
  33. the `bucket_span` parameter (to a value greater than its default), the
  34. `overall_score` is the maximum `overall_score` of the overall buckets that have
  35. a span equal to the jobs' largest bucket span.
  36. [[ml-get-overall-buckets-path-parms]]
  37. == {api-path-parms-title}
  38. `<job_id>`::
  39. (Required, string)
  40. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-wildcard-list]
  41. +
  42. You can summarize the bucket results for all {anomaly-jobs} by using `_all` or
  43. by specifying `*` as the job identifier.
  44. [[ml-get-overall-buckets-query-parms]]
  45. == {api-query-parms-title}
  46. `allow_no_match`::
  47. (Optional, Boolean)
  48. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-jobs]
  49. `bucket_span`::
  50. (Optional, string) The span of the overall buckets. Must be greater or equal to
  51. the largest bucket span of the specified {anomaly-jobs}, which is the default
  52. value.
  53. `end`::
  54. (Optional, string) Returns overall buckets with timestamps earlier than this
  55. time. Defaults to `-1`, which means it is unset and results are not limited to
  56. specific timestamps.
  57. `exclude_interim`::
  58. (Optional, Boolean) If `true`, the output excludes interim overall buckets.
  59. Overall buckets are interim if any of the job buckets within the overall bucket
  60. interval are interim. Defaults to `false`, which means interim results are
  61. included.
  62. `overall_score`::
  63. (Optional, double) Returns overall buckets with overall scores greater or equal
  64. than this value. Defaults to `0.0`.
  65. `start`::
  66. (Optional, string) Returns overall buckets with timestamps after this time.
  67. Defaults to `-1`, which means it is unset and results are not limited to
  68. specific timestamps.
  69. `top_n`::
  70. (Optional, integer) The number of top {anomaly-job} bucket scores to be used in
  71. the `overall_score` calculation. Defaults to `1`.
  72. [[ml-get-overall-buckets-request-body]]
  73. == {api-request-body-title}
  74. You can also specify the query parameters (such as `allow_no_match` and
  75. `bucket_span`) in the request body.
  76. [[ml-get-overall-buckets-results]]
  77. == {api-response-body-title}
  78. The API returns an array of overall bucket objects, which have the following
  79. properties:
  80. `bucket_span`::
  81. (number) The length of the bucket in seconds. Matches the `bucket_span`
  82. of the job with the longest one.
  83. `is_interim`::
  84. (Boolean)
  85. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=is-interim]
  86. `jobs`::
  87. (array) An array of objects that contain the `max_anomaly_score` per `job_id`.
  88. `overall_score`::
  89. (number) The `top_n` average of the max bucket `anomaly_score` per job.
  90. `result_type`::
  91. (string) Internal. This is always set to `overall_bucket`.
  92. `timestamp`::
  93. (date)
  94. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=timestamp-results]
  95. [[ml-get-overall-buckets-example]]
  96. == {api-examples-title}
  97. [source,console]
  98. --------------------------------------------------
  99. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  100. {
  101. "overall_score": 80,
  102. "start": "1403532000000"
  103. }
  104. --------------------------------------------------
  105. // TEST[skip:todo]
  106. In this example, the API returns a single result that matches the specified
  107. score and time constraints. The `overall_score` is the max job score as
  108. `top_n` defaults to 1 when not specified:
  109. [source,js]
  110. ----
  111. {
  112. "count": 1,
  113. "overall_buckets": [
  114. {
  115. "timestamp" : 1403532000000,
  116. "bucket_span" : 3600,
  117. "overall_score" : 80.0,
  118. "jobs" : [
  119. {
  120. "job_id" : "job-1",
  121. "max_anomaly_score" : 30.0
  122. },
  123. {
  124. "job_id" : "job-2",
  125. "max_anomaly_score" : 10.0
  126. },
  127. {
  128. "job_id" : "job-3",
  129. "max_anomaly_score" : 80.0
  130. }
  131. ],
  132. "is_interim" : false,
  133. "result_type" : "overall_bucket"
  134. }
  135. ]
  136. }
  137. ----
  138. The next example is similar but this time `top_n` is set to `2`:
  139. [source,console]
  140. --------------------------------------------------
  141. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  142. {
  143. "top_n": 2,
  144. "overall_score": 50.0,
  145. "start": "1403532000000"
  146. }
  147. --------------------------------------------------
  148. // TEST[skip:todo]
  149. Note how the `overall_score` is now the average of the top 2 job scores:
  150. [source,js]
  151. ----
  152. {
  153. "count": 1,
  154. "overall_buckets": [
  155. {
  156. "timestamp" : 1403532000000,
  157. "bucket_span" : 3600,
  158. "overall_score" : 55.0,
  159. "jobs" : [
  160. {
  161. "job_id" : "job-1",
  162. "max_anomaly_score" : 30.0
  163. },
  164. {
  165. "job_id" : "job-2",
  166. "max_anomaly_score" : 10.0
  167. },
  168. {
  169. "job_id" : "job-3",
  170. "max_anomaly_score" : 80.0
  171. }
  172. ],
  173. "is_interim" : false,
  174. "result_type" : "overall_bucket"
  175. }
  176. ]
  177. }
  178. ----