get-overall-buckets.asciidoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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
  9. bucket results of multiple 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 jobs by using `_all` or by
  26. specifying `*` as the `<job_id>`.
  27. An overall bucket has a span equal to the largest `bucket_span` value for the
  28. specified jobs.
  29. The `overall_score` is calculated by combining the scores of all
  30. the buckets within the overall bucket span. First, the maximum `anomaly_score` per
  31. job in the overall bucket is calculated. Then the `top_n` of those scores are
  32. averaged to result in the `overall_score`. This means that you can fine-tune
  33. 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
  36. score in the overall bucket. Alternatively, if you set `top_n` to the number of
  37. jobs, the `overall_score` is high only when all jobs detect anomalies in that
  38. overall bucket.
  39. In addition, the optional parameter `bucket_span` may be used in order
  40. to request overall buckets that span longer than the largest job's `bucket_span`.
  41. When set, the `overall_score` will be the max `overall_score` of the corresponding
  42. overall buckets with a span equal to the largest job's `bucket_span`.
  43. [[ml-get-overall-buckets-path-parms]]
  44. ==== {api-path-parms-title}
  45. `<job_id>`::
  46. (Required, string) Identifier for the job. It can be a job identifier, a group
  47. name, a comma-separated list of jobs or groups, or a 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 job, an
  52. 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 largest job's `bucket_span`. Defaults to the largest job's `bucket_span`.
  56. `end`::
  57. (Optional, string) Returns overall buckets with timestamps earlier than this
  58. time.
  59. `exclude_interim`::
  60. (Optional, boolean) If `true`, the output excludes interim overall buckets.
  61. Overall buckets are interim if any of the job buckets within the overall
  62. bucket interval are interim. By default, interim results are included.
  63. `overall_score`::
  64. (Optional, double) Returns overall buckets with overall scores greater or
  65. equal than this value.
  66. `start`::
  67. (Optional, string) Returns overall buckets with timestamps after this time.
  68. `top_n`::
  69. (Optional, integer) The number of top job bucket scores to be used in the
  70. `overall_score` calculation. The default value is `1`.
  71. [[ml-get-overall-buckets-results]]
  72. ==== {api-response-body-title}
  73. The API returns the following information:
  74. `overall_buckets`::
  75. (array) An array of overall bucket objects. For more information, see
  76. <<ml-results-overall-buckets,Overall Buckets>>.
  77. [[ml-get-overall-buckets-example]]
  78. ==== {api-examples-title}
  79. The following example gets overall buckets for jobs with IDs matching `job-*`:
  80. [source,js]
  81. --------------------------------------------------
  82. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  83. {
  84. "overall_score": 80,
  85. "start": "1403532000000"
  86. }
  87. --------------------------------------------------
  88. // CONSOLE
  89. // TEST[skip:todo]
  90. In this example, the API returns a single result that matches the specified
  91. score and time constraints. The `overall_score` is the max job score as
  92. `top_n` defaults to 1 when not specified:
  93. [source,js]
  94. ----
  95. {
  96. "count": 1,
  97. "overall_buckets": [
  98. {
  99. "timestamp" : 1403532000000,
  100. "bucket_span" : 3600,
  101. "overall_score" : 80.0,
  102. "jobs" : [
  103. {
  104. "job_id" : "job-1",
  105. "max_anomaly_score" : 30.0
  106. },
  107. {
  108. "job_id" : "job-2",
  109. "max_anomaly_score" : 10.0
  110. },
  111. {
  112. "job_id" : "job-3",
  113. "max_anomaly_score" : 80.0
  114. }
  115. ],
  116. "is_interim" : false,
  117. "result_type" : "overall_bucket"
  118. }
  119. ]
  120. }
  121. ----
  122. The next example is similar but this time `top_n` is set to `2`:
  123. [source,js]
  124. --------------------------------------------------
  125. GET _ml/anomaly_detectors/job-*/results/overall_buckets
  126. {
  127. "top_n": 2,
  128. "overall_score": 50.0,
  129. "start": "1403532000000"
  130. }
  131. --------------------------------------------------
  132. // CONSOLE
  133. // TEST[skip:todo]
  134. Note how the `overall_score` is now the average of the top 2 job scores:
  135. [source,js]
  136. ----
  137. {
  138. "count": 1,
  139. "overall_buckets": [
  140. {
  141. "timestamp" : 1403532000000,
  142. "bucket_span" : 3600,
  143. "overall_score" : 55.0,
  144. "jobs" : [
  145. {
  146. "job_id" : "job-1",
  147. "max_anomaly_score" : 30.0
  148. },
  149. {
  150. "job_id" : "job-2",
  151. "max_anomaly_score" : 10.0
  152. },
  153. {
  154. "job_id" : "job-3",
  155. "max_anomaly_score" : 80.0
  156. }
  157. ],
  158. "is_interim" : false,
  159. "result_type" : "overall_bucket"
  160. }
  161. ]
  162. }
  163. ----