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