get-record.asciidoc 2.9 KB

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