get-bucket.asciidoc 3.5 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 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-desc]]
  14. ==== {api-description-title}
  15. The get buckets API presents a chronological view of the records, grouped by
  16. bucket.
  17. [[ml-get-bucket-path-parms]]
  18. ==== {api-path-parms-title}
  19. `job_id`::
  20. (string) Identifier for the job
  21. `timestamp`::
  22. (string) The timestamp of a single bucket result.
  23. If you do not specify this optional parameter, the API returns information
  24. about all buckets.
  25. [[ml-get-bucket-request-body]]
  26. ==== {api-request-body-title}
  27. `anomaly_score`::
  28. (double) Returns buckets with anomaly scores greater or equal than this value.
  29. `desc`::
  30. (boolean) If true, the buckets are sorted in descending order.
  31. `end`::
  32. (string) Returns buckets with timestamps earlier than this time.
  33. `exclude_interim`::
  34. (boolean) If true, the output excludes interim results.
  35. By default, interim results are included.
  36. `expand`::
  37. (boolean) If true, the output includes anomaly records.
  38. `page`::
  39. `from`:::
  40. (integer) Skips the specified number of buckets.
  41. `size`:::
  42. (integer) Specifies the maximum number of buckets to obtain.
  43. `sort`::
  44. (string) Specifies the sort field for the requested buckets.
  45. By default, the buckets are sorted by the `timestamp` field.
  46. `start`::
  47. (string) Returns buckets with timestamps after this time.
  48. [[ml-get-bucket-results]]
  49. ==== {api-response-body-title}
  50. The API returns the following information:
  51. `buckets`::
  52. (array) An array of bucket objects. For more information, see
  53. <<ml-results-buckets,Buckets>>.
  54. [[ml-get-bucket-prereqs]]
  55. ==== {api-prereq-title}
  56. You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
  57. privileges to use this API. You also need `read` index privilege on the index
  58. that stores the results. The `machine_learning_admin` and `machine_learning_user`
  59. roles provide these privileges. For more information, see
  60. {stack-ov}/security-privileges.html[Security Privileges] and
  61. {stack-ov}/built-in-roles.html[Built-in Roles].
  62. [[ml-get-bucket-example]]
  63. ==== {api-examples-title}
  64. The following example gets bucket information for the `it-ops-kpi` job:
  65. [source,js]
  66. --------------------------------------------------
  67. GET _ml/anomaly_detectors/it-ops-kpi/results/buckets
  68. {
  69. "anomaly_score": 80,
  70. "start": "1454530200001"
  71. }
  72. --------------------------------------------------
  73. // CONSOLE
  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. ----