get-category.asciidoc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-category]]
  4. === Get categories API
  5. ++++
  6. <titleabbrev>Get categories</titleabbrev>
  7. ++++
  8. Retrieves job results for one or more categories.
  9. [[ml-get-category-request]]
  10. ==== {api-request-title}
  11. `GET _ml/anomaly_detectors/<job_id>/results/categories` +
  12. `GET _ml/anomaly_detectors/<job_id>/results/categories/<category_id>`
  13. [[ml-get-category-desc]]
  14. ==== {api-description-title}
  15. For more information about categories, see
  16. {stack-ov}/ml-configuring-categories.html[Categorizing Log Messages].
  17. [[ml-get-category-path-parms]]
  18. ==== {api-path-parms-title}
  19. `job_id`::
  20. (string) Identifier for the job.
  21. `category_id`::
  22. (long) Identifier for the category. If you do not specify this optional parameter,
  23. the API returns information about all categories in the job.
  24. [[ml-get-category-request-body]]
  25. ==== {api-request-body-title}
  26. `page`::
  27. `from`:::
  28. (integer) Skips the specified number of categories.
  29. `size`:::
  30. (integer) Specifies the maximum number of categories to obtain.
  31. [[ml-get-category-results]]
  32. ==== {api-response-body-title}
  33. The API returns the following information:
  34. `categories`::
  35. (array) An array of category objects. For more information, see
  36. <<ml-results-categories,Categories>>.
  37. [[ml-get-category-prereqs]]
  38. ==== {api-prereq-title}
  39. You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
  40. privileges to use this API. You also need `read` index privilege on the index
  41. that stores the results. The `machine_learning_admin` and `machine_learning_user`
  42. roles provide these privileges. For more information, see
  43. {stack-ov}/security-privileges.html[Security Privileges] and
  44. {stack-ov}/built-in-roles.html[Built-in Roles].
  45. [[ml-get-category-example]]
  46. ==== {api-examples-title}
  47. The following example gets information about one category for the
  48. `esxi_log` job:
  49. [source,js]
  50. --------------------------------------------------
  51. GET _ml/anomaly_detectors/esxi_log/results/categories
  52. {
  53. "page":{
  54. "size": 1
  55. }
  56. }
  57. --------------------------------------------------
  58. // CONSOLE
  59. // TEST[skip:todo]
  60. In this example, the API returns the following information:
  61. [source,js]
  62. ----
  63. {
  64. "count": 11,
  65. "categories": [
  66. {
  67. "job_id" : "esxi_log",
  68. "category_id" : 1,
  69. "terms" : "Vpxa verbose vpxavpxaInvtVm opID VpxaInvtVmChangeListener Guest DiskInfo Changed",
  70. "regex" : ".*?Vpxa.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*",
  71. "max_matching_length": 154,
  72. "examples" : [
  73. "Oct 19 17:04:44 esxi1.acme.com Vpxa: [3CB3FB90 verbose 'vpxavpxaInvtVm' opID=WFU-33d82c31] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  74. "Oct 19 17:04:45 esxi2.acme.com Vpxa: [3CA66B90 verbose 'vpxavpxaInvtVm' opID=WFU-33927856] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  75. "Oct 19 17:04:51 esxi1.acme.com Vpxa: [FFDBAB90 verbose 'vpxavpxaInvtVm' opID=WFU-25e0d447] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  76. "Oct 19 17:04:58 esxi2.acme.com Vpxa: [FFDDBB90 verbose 'vpxavpxaInvtVm' opID=WFU-bbff0134] [VpxaInvtVmChangeListener] Guest DiskInfo Changed"
  77. ],
  78. "grok_pattern" : ".*?%{SYSLOGTIMESTAMP:timestamp}.+?Vpxa.+?%{BASE16NUM:field}.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*"
  79. }
  80. ]
  81. }
  82. ----