get-record.asciidoc 2.9 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 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)
  23. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  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>>.
  52. [[ml-get-record-example]]
  53. ==== {api-examples-title}
  54. The following example gets record information for the `it-ops-kpi` job:
  55. [source,console]
  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. // 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. ----