get-record.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 an {anomaly-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 <<security-privileges>> and <<built-in-roles>>.
  19. [[ml-get-record-path-parms]]
  20. ==== {api-path-parms-title}
  21. `<job_id>`::
  22. (Required, string) Identifier for the {anomaly-job}.
  23. [[ml-get-record-request-body]]
  24. ==== {api-request-body-title}
  25. `desc`::
  26. (Optional, boolean) If true, the results are sorted in descending order.
  27. `end`::
  28. (Optional, string) Returns records with timestamps earlier than this time.
  29. `exclude_interim`::
  30. (Optional, boolean) If true, the output excludes interim results. By default,
  31. interim results are included.
  32. `page`::
  33. `from`:::
  34. (Optional, integer) Skips the specified number of records.
  35. `size`:::
  36. (Optional, integer) Specifies the maximum number of records to obtain.
  37. `record_score`::
  38. (Optional, double) Returns records with anomaly scores greater or equal than
  39. this value.
  40. `sort`::
  41. (Optional, string) Specifies the sort field for the requested records. By
  42. default, the records are sorted by the `anomaly_score` value.
  43. `start`::
  44. (Optional, string) Returns records with timestamps after this time.
  45. [[ml-get-record-results]]
  46. ==== {api-response-body-title}
  47. The API returns the following information:
  48. `records`::
  49. (array) An array of record objects. For more information, see
  50. <<ml-results-records>>.
  51. [[ml-get-record-example]]
  52. ==== {api-examples-title}
  53. The following example gets record information for the `it-ops-kpi` job:
  54. [source,console]
  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. // TEST[skip:todo]
  64. In this example, the API returns twelve results for the specified
  65. time constraints:
  66. [source,js]
  67. ----
  68. {
  69. "count": 12,
  70. "records": [
  71. {
  72. "job_id": "it-ops-kpi",
  73. "result_type": "record",
  74. "probability": 0.00000332668,
  75. "record_score": 72.9929,
  76. "initial_record_score": 65.7923,
  77. "bucket_span": 300,
  78. "detector_index": 0,
  79. "is_interim": false,
  80. "timestamp": 1454944200000,
  81. "function": "low_sum",
  82. "function_description": "sum",
  83. "typical": [
  84. 1806.48
  85. ],
  86. "actual": [
  87. 288
  88. ],
  89. "field_name": "events_per_min"
  90. },
  91. ...
  92. ]
  93. }
  94. ----