get-record.asciidoc 2.6 KB

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