get-record.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-record]]
  4. === Get records API
  5. ++++
  6. <titleabbrev>Get records</titleabbrev>
  7. ++++
  8. Retrieves anomaly records for a job.
  9. [[ml-get-record-request]]
  10. ==== {api-request-title}
  11. `GET _ml/anomaly_detectors/<job_id>/results/records`
  12. [[ml-get-record-path-parms]]
  13. ==== {api-path-parms-title}
  14. `job_id`::
  15. (string) Identifier for the job.
  16. [[ml-get-record-request-body]]
  17. ==== {api-request-body-title}
  18. `desc`::
  19. (boolean) If true, the results are sorted in descending order.
  20. `end`::
  21. (string) Returns records with timestamps earlier than this time.
  22. `exclude_interim`::
  23. (boolean) If true, the output excludes interim results.
  24. By default, interim results are included.
  25. `page`::
  26. `from`:::
  27. (integer) Skips the specified number of records.
  28. `size`:::
  29. (integer) Specifies the maximum number of records to obtain.
  30. `record_score`::
  31. (double) Returns records with anomaly scores greater or equal than this value.
  32. `sort`::
  33. (string) Specifies the sort field for the requested records.
  34. By default, the records are sorted by the `anomaly_score` value.
  35. `start`::
  36. (string) Returns records with timestamps after this time.
  37. [[ml-get-record-results]]
  38. ==== {api-response-body-title}
  39. The API returns the following information:
  40. `records`::
  41. (array) An array of record objects. For more information, see
  42. <<ml-results-records,Records>>.
  43. [[ml-get-record-prereqs]]
  44. ==== {api-prereq-title}
  45. You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
  46. privileges to use this API. You also need `read` index privilege on the index
  47. that stores the results. The `machine_learning_admin` and `machine_learning_user`
  48. roles provide these privileges. For more information, see
  49. {stack-ov}/security-privileges.html[Security privileges] and
  50. {stack-ov}/built-in-roles.html[Built-in roles].
  51. [[ml-get-record-example]]
  52. ==== {api-examples-title}
  53. The following example gets record information for the `it-ops-kpi` job:
  54. [source,js]
  55. --------------------------------------------------
  56. GET _ml/anomaly_detectors/it-ops-kpi/results/records
  57. {
  58. "sort": "record_score",
  59. "desc": true,
  60. "start": "1454944100000"
  61. }
  62. --------------------------------------------------
  63. // CONSOLE
  64. // TEST[skip:todo]
  65. In this example, the API returns twelve results for the specified
  66. time constraints:
  67. [source,js]
  68. ----
  69. {
  70. "count": 12,
  71. "records": [
  72. {
  73. "job_id": "it-ops-kpi",
  74. "result_type": "record",
  75. "probability": 0.00000332668,
  76. "record_score": 72.9929,
  77. "initial_record_score": 65.7923,
  78. "bucket_span": 300,
  79. "detector_index": 0,
  80. "is_interim": false,
  81. "timestamp": 1454944200000,
  82. "function": "low_sum",
  83. "function_description": "sum",
  84. "typical": [
  85. 1806.48
  86. ],
  87. "actual": [
  88. 288
  89. ],
  90. "field_name": "events_per_min"
  91. },
  92. ...
  93. ]
  94. }
  95. ----