get-overall-buckets.asciidoc 5.3 KB

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