get-bucket.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. <<security-privileges>> and
  21. <<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)
  30. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  31. `<timestamp>`::
  32. (Optional, string) The timestamp of a single bucket result. If you do not
  33. specify this parameter, the API returns information about all buckets.
  34. [[ml-get-bucket-request-body]]
  35. ==== {api-request-body-title}
  36. `anomaly_score`::
  37. (Optional, double) Returns buckets with anomaly scores greater or equal than
  38. this value.
  39. `desc`::
  40. (Optional, boolean) If true, the buckets are sorted in descending order.
  41. `end`::
  42. (Optional, string) Returns buckets with timestamps earlier than this time.
  43. `exclude_interim`::
  44. (Optional, boolean) If true, the output excludes interim results. By default,
  45. interim results are included.
  46. `expand`::
  47. (Optional, boolean) If true, the output includes anomaly records.
  48. `page`::
  49. `from`:::
  50. (Optional, integer) Skips the specified number of buckets.
  51. `size`:::
  52. (Optional, integer) Specifies the maximum number of buckets to obtain.
  53. `sort`::
  54. (Optional, string) Specifies the sort field for the requested buckets. By
  55. default, the buckets are sorted by the `timestamp` field.
  56. `start`::
  57. (Optional, string) Returns buckets with timestamps after this time.
  58. [[ml-get-bucket-results]]
  59. ==== {api-response-body-title}
  60. The API returns the following information:
  61. `buckets`::
  62. (array) An array of bucket objects. For more information, see
  63. <<ml-results-buckets,Buckets>>.
  64. [[ml-get-bucket-example]]
  65. ==== {api-examples-title}
  66. The following example gets bucket information for the `it-ops-kpi` job:
  67. [source,console]
  68. --------------------------------------------------
  69. GET _ml/anomaly_detectors/it-ops-kpi/results/buckets
  70. {
  71. "anomaly_score": 80,
  72. "start": "1454530200001"
  73. }
  74. --------------------------------------------------
  75. // TEST[skip:todo]
  76. In this example, the API returns a single result that matches the specified
  77. score and time constraints:
  78. [source,js]
  79. ----
  80. {
  81. "count": 1,
  82. "buckets": [
  83. {
  84. "job_id": "it-ops-kpi",
  85. "timestamp": 1454943900000,
  86. "anomaly_score": 94.1706,
  87. "bucket_span": 300,
  88. "initial_anomaly_score": 94.1706,
  89. "event_count": 153,
  90. "is_interim": false,
  91. "bucket_influencers": [
  92. {
  93. "job_id": "it-ops-kpi",
  94. "result_type": "bucket_influencer",
  95. "influencer_field_name": "bucket_time",
  96. "initial_anomaly_score": 94.1706,
  97. "anomaly_score": 94.1706,
  98. "raw_anomaly_score": 2.32119,
  99. "probability": 0.00000575042,
  100. "timestamp": 1454943900000,
  101. "bucket_span": 300,
  102. "is_interim": false
  103. }
  104. ],
  105. "processing_time_ms": 2,
  106. "partition_scores": [],
  107. "result_type": "bucket"
  108. }
  109. ]
  110. }
  111. ----