get-overall-buckets.asciidoc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-overall-buckets]]
  4. === Get overall buckets API
  5. ++++
  6. <titleabbrev>Get overall buckets</titleabbrev>
  7. ++++
  8. Retrieves overall bucket results that summarize the bucket results of multiple
  9. {anomaly-jobs}.
  10. [[ml-get-overall-buckets-request]]
  11. ==== {api-request-title}
  12. `GET _ml/anomaly_detectors/<job_id>/results/overall_buckets` +
  13. `GET _ml/anomaly_detectors/<job_id>,<job_id>/results/overall_buckets` +
  14. `GET _ml/anomaly_detectors/_all/results/overall_buckets`
  15. [[ml-get-overall-buckets-prereqs]]
  16. ==== {api-prereq-title}
  17. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  18. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. You also
  19. need `read` index privilege on the index that stores the results. The
  20. `machine_learning_admin` and `machine_learning_user` roles provide these
  21. privileges. See {stack-ov}/security-privileges.html[Security privileges] and
  22. {stack-ov}/built-in-roles.html[Built-in roles].
  23. [[ml-get-overall-buckets-desc]]
  24. ==== {api-description-title}
  25. You can summarize the bucket results for all {anomaly-jobs} by using `_all` or
  26. by specifying `*` as the `<job_id>`.
  27. An overall bucket has a span equal to the largest `bucket_span` value for the
  28. specified {anomaly-jobs}.
  29. The `overall_score` is calculated by combining the scores of all the buckets
  30. within the overall bucket span. First, the maximum `anomaly_score` per
  31. {anomaly-job} in the overall bucket is calculated. Then the `top_n` of those
  32. scores are averaged to result in the `overall_score`. This means that you can
  33. fine-tune the `overall_score` so that it is more or less sensitive to the number
  34. of jobs that detect an anomaly at the same time. For example, if you set `top_n`
  35. to `1`, the `overall_score` is the maximum bucket score in the overall bucket. Alternatively, if you set `top_n` to the number of jobs, the `overall_score` is
  36. high only when all jobs detect anomalies in that overall bucket.
  37. In addition, the optional parameter `bucket_span` may be used in order
  38. to request overall buckets that span longer than the `bucket_span` of the
  39. largest {anomaly-job}. When set, the `overall_score` will be the max
  40. `overall_score` of the corresponding overall buckets with a span equal to the
  41. `bucket_span` of the largest {anomaly-job}.
  42. [[ml-get-overall-buckets-path-parms]]
  43. ==== {api-path-parms-title}
  44. `<job_id>`::
  45. (Required, string) Identifier for the {anomaly-job}. It can be a job
  46. identifier, a group name, a comma-separated list of jobs or groups, or a
  47. wildcard expression.
  48. [[ml-get-overall-buckets-request-body]]
  49. ==== {api-request-body-title}
  50. `allow_no_jobs`::
  51. (Optional, boolean) If `false` and the `job_id` does not match any
  52. {anomaly-jobs}, an error occurs. The default value is `true`.
  53. `bucket_span`::
  54. (Optional, string) The span of the overall buckets. Must be greater or equal
  55. to the `bucket_span` of the largest {anomaly-job}. Defaults to the
  56. `bucket_span` of the largest {anomaly-job}.
  57. `end`::
  58. (Optional, string) Returns overall buckets with timestamps earlier than this
  59. time.
  60. `exclude_interim`::
  61. (Optional, boolean) If `true`, the output excludes interim overall buckets.
  62. Overall buckets are interim if any of the job buckets within the overall
  63. bucket interval are interim. By default, interim results are included.
  64. `overall_score`::
  65. (Optional, double) Returns overall buckets with overall scores greater or
  66. equal than this value.
  67. `start`::
  68. (Optional, string) Returns overall buckets with timestamps after this time.
  69. `top_n`::
  70. (Optional, integer) The number of top {anomaly-job} bucket scores to be used
  71. in the `overall_score` calculation. The default value is `1`.
  72. [[ml-get-overall-buckets-results]]
  73. ==== {api-response-body-title}
  74. The API returns the following information:
  75. `overall_buckets`::
  76. (array) An array of overall bucket objects. For more information, see
  77. <<ml-results-overall-buckets,Overall Buckets>>.
  78. [[ml-get-overall-buckets-example]]
  79. ==== {api-examples-title}
  80. The following example gets overall buckets for {anomaly-jobs} with IDs matching
  81. `job-*`:
  82. [source,js]
  83. --------------------------------------------------
  84. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  85. {
  86. "overall_score": 80,
  87. "start": "1403532000000"
  88. }
  89. --------------------------------------------------
  90. // CONSOLE
  91. // TEST[skip:todo]
  92. In this example, the API returns a single result that matches the specified
  93. score and time constraints. The `overall_score` is the max job score as
  94. `top_n` defaults to 1 when not specified:
  95. [source,js]
  96. ----
  97. {
  98. "count": 1,
  99. "overall_buckets": [
  100. {
  101. "timestamp" : 1403532000000,
  102. "bucket_span" : 3600,
  103. "overall_score" : 80.0,
  104. "jobs" : [
  105. {
  106. "job_id" : "job-1",
  107. "max_anomaly_score" : 30.0
  108. },
  109. {
  110. "job_id" : "job-2",
  111. "max_anomaly_score" : 10.0
  112. },
  113. {
  114. "job_id" : "job-3",
  115. "max_anomaly_score" : 80.0
  116. }
  117. ],
  118. "is_interim" : false,
  119. "result_type" : "overall_bucket"
  120. }
  121. ]
  122. }
  123. ----
  124. The next example is similar but this time `top_n` is set to `2`:
  125. [source,js]
  126. --------------------------------------------------
  127. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  128. {
  129. "top_n": 2,
  130. "overall_score": 50.0,
  131. "start": "1403532000000"
  132. }
  133. --------------------------------------------------
  134. // CONSOLE
  135. // TEST[skip:todo]
  136. Note how the `overall_score` is now the average of the top 2 job scores:
  137. [source,js]
  138. ----
  139. {
  140. "count": 1,
  141. "overall_buckets": [
  142. {
  143. "timestamp" : 1403532000000,
  144. "bucket_span" : 3600,
  145. "overall_score" : 55.0,
  146. "jobs" : [
  147. {
  148. "job_id" : "job-1",
  149. "max_anomaly_score" : 30.0
  150. },
  151. {
  152. "job_id" : "job-2",
  153. "max_anomaly_score" : 10.0
  154. },
  155. {
  156. "job_id" : "job-3",
  157. "max_anomaly_score" : 80.0
  158. }
  159. ],
  160. "is_interim" : false,
  161. "result_type" : "overall_bucket"
  162. }
  163. ]
  164. }
  165. ----