get-bucket.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-bucket]]
  4. === Get buckets API
  5. ++++
  6. <titleabbrev>Get buckets</titleabbrev>
  7. ++++
  8. Retrieves {anomaly-job} results for one or more buckets.
  9. [[ml-get-bucket-request]]
  10. ==== {api-request-title}
  11. `GET _ml/anomaly_detectors/<job_id>/results/buckets` +
  12. `GET _ml/anomaly_detectors/<job_id>/results/buckets/<timestamp>`
  13. [[ml-get-bucket-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  16. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. You also
  17. need `read` index privilege on the index that stores the results. The
  18. `machine_learning_admin` and `machine_learning_user` roles provide these
  19. privileges. For more information, see
  20. {stack-ov}/security-privileges.html[Security privileges] and
  21. {stack-ov}/built-in-roles.html[Built-in roles].
  22. [[ml-get-bucket-desc]]
  23. ==== {api-description-title}
  24. The get buckets API presents a chronological view of the records, grouped by
  25. bucket.
  26. [[ml-get-bucket-path-parms]]
  27. ==== {api-path-parms-title}
  28. `<job_id>`::
  29. (Required, string) Identifier for the {anomaly-job}.
  30. `<timestamp>`::
  31. (Optional, string) The timestamp of a single bucket result. If you do not
  32. specify this parameter, the API returns information about all buckets.
  33. [[ml-get-bucket-request-body]]
  34. ==== {api-request-body-title}
  35. `anomaly_score`::
  36. (Optional, double) Returns buckets with anomaly scores greater or equal than
  37. this value.
  38. `desc`::
  39. (Optional, boolean) If true, the buckets are sorted in descending order.
  40. `end`::
  41. (Optional, string) Returns buckets with timestamps earlier than this time.
  42. `exclude_interim`::
  43. (Optional, boolean) If true, the output excludes interim results. By default,
  44. interim results are included.
  45. `expand`::
  46. (Optional, boolean) If true, the output includes anomaly records.
  47. `page`::
  48. `from`:::
  49. (Optional, integer) Skips the specified number of buckets.
  50. `size`:::
  51. (Optional, integer) Specifies the maximum number of buckets to obtain.
  52. `sort`::
  53. (Optional, string) Specifies the sort field for the requested buckets. By
  54. default, the buckets are sorted by the `timestamp` field.
  55. `start`::
  56. (Optional, string) Returns buckets with timestamps after this time.
  57. [[ml-get-bucket-results]]
  58. ==== {api-response-body-title}
  59. The API returns the following information:
  60. `buckets`::
  61. (array) An array of bucket objects. For more information, see
  62. <<ml-results-buckets,Buckets>>.
  63. [[ml-get-bucket-example]]
  64. ==== {api-examples-title}
  65. The following example gets bucket information for the `it-ops-kpi` job:
  66. [source,console]
  67. --------------------------------------------------
  68. GET _ml/anomaly_detectors/it-ops-kpi/results/buckets
  69. {
  70. "anomaly_score": 80,
  71. "start": "1454530200001"
  72. }
  73. --------------------------------------------------
  74. // TEST[skip:todo]
  75. In this example, the API returns a single result that matches the specified
  76. score and time constraints:
  77. [source,js]
  78. ----
  79. {
  80. "count": 1,
  81. "buckets": [
  82. {
  83. "job_id": "it-ops-kpi",
  84. "timestamp": 1454943900000,
  85. "anomaly_score": 94.1706,
  86. "bucket_span": 300,
  87. "initial_anomaly_score": 94.1706,
  88. "event_count": 153,
  89. "is_interim": false,
  90. "bucket_influencers": [
  91. {
  92. "job_id": "it-ops-kpi",
  93. "result_type": "bucket_influencer",
  94. "influencer_field_name": "bucket_time",
  95. "initial_anomaly_score": 94.1706,
  96. "anomaly_score": 94.1706,
  97. "raw_anomaly_score": 2.32119,
  98. "probability": 0.00000575042,
  99. "timestamp": 1454943900000,
  100. "bucket_span": 300,
  101. "is_interim": false
  102. }
  103. ],
  104. "processing_time_ms": 2,
  105. "partition_scores": [],
  106. "result_type": "bucket"
  107. }
  108. ]
  109. }
  110. ----