get-category.asciidoc 3.3 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-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  16. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. You also
  17. need `read` index privilege on the index that stores the results. The
  18. `machine_learning_admin` and `machine_learning_user` roles provide these
  19. privileges. See {stack-ov}/security-privileges.html[Security privileges] and
  20. {stack-ov}/built-in-roles.html[Built-in roles].
  21. [[ml-get-category-desc]]
  22. ==== {api-description-title}
  23. For more information about categories, see
  24. {stack-ov}/ml-configuring-categories.html[Categorizing log messages].
  25. [[ml-get-category-path-parms]]
  26. ==== {api-path-parms-title}
  27. `<job_id>`::
  28. (Required, string) Identifier for the job.
  29. `<category_id>`::
  30. (Optional, long) Identifier for the category. If you do not specify this
  31. parameter, the API returns information about all categories in the job.
  32. [[ml-get-category-request-body]]
  33. ==== {api-request-body-title}
  34. `page`::
  35. `from`:::
  36. (Optional, integer) Skips the specified number of categories.
  37. `size`:::
  38. (Optional, integer) Specifies the maximum number of categories to obtain.
  39. [[ml-get-category-results]]
  40. ==== {api-response-body-title}
  41. The API returns the following information:
  42. `categories`::
  43. (array) An array of category objects. For more information, see
  44. <<ml-results-categories,Categories>>.
  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. ----