get-overall-buckets.asciidoc 6.0 KB

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