get-category.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-category]]
  4. === Get categories API
  5. ++++
  6. <titleabbrev>Get categories</titleabbrev>
  7. ++++
  8. Retrieves {anomaly-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 <<security-privileges>> and
  20. <<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)
  29. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  30. `<category_id>`::
  31. (Optional, long) Identifier for the category. If you do not specify this
  32. parameter, the API returns information about all categories in the
  33. {anomaly-job}.
  34. [[ml-get-category-request-body]]
  35. ==== {api-request-body-title}
  36. `page`::
  37. `from`:::
  38. (Optional, integer) Skips the specified number of categories.
  39. `size`:::
  40. (Optional, integer) Specifies the maximum number of categories to obtain.
  41. [[ml-get-category-results]]
  42. ==== {api-response-body-title}
  43. The API returns the following information:
  44. `categories`::
  45. (array) An array of category objects. For more information, see
  46. <<ml-results-categories,Categories>>.
  47. [[ml-get-category-example]]
  48. ==== {api-examples-title}
  49. The following example gets information about one category for the
  50. `esxi_log` job:
  51. [source,console]
  52. --------------------------------------------------
  53. GET _ml/anomaly_detectors/esxi_log/results/categories
  54. {
  55. "page":{
  56. "size": 1
  57. }
  58. }
  59. --------------------------------------------------
  60. // TEST[skip:todo]
  61. In this example, the API returns the following information:
  62. [source,js]
  63. ----
  64. {
  65. "count": 11,
  66. "categories": [
  67. {
  68. "job_id" : "esxi_log",
  69. "category_id" : 1,
  70. "terms" : "Vpxa verbose vpxavpxaInvtVm opID VpxaInvtVmChangeListener Guest DiskInfo Changed",
  71. "regex" : ".*?Vpxa.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*",
  72. "max_matching_length": 154,
  73. "examples" : [
  74. "Oct 19 17:04:44 esxi1.acme.com Vpxa: [3CB3FB90 verbose 'vpxavpxaInvtVm' opID=WFU-33d82c31] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  75. "Oct 19 17:04:45 esxi2.acme.com Vpxa: [3CA66B90 verbose 'vpxavpxaInvtVm' opID=WFU-33927856] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  76. "Oct 19 17:04:51 esxi1.acme.com Vpxa: [FFDBAB90 verbose 'vpxavpxaInvtVm' opID=WFU-25e0d447] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  77. "Oct 19 17:04:58 esxi2.acme.com Vpxa: [FFDDBB90 verbose 'vpxavpxaInvtVm' opID=WFU-bbff0134] [VpxaInvtVmChangeListener] Guest DiskInfo Changed"
  78. ],
  79. "grok_pattern" : ".*?%{SYSLOGTIMESTAMP:timestamp}.+?Vpxa.+?%{BASE16NUM:field}.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*"
  80. }
  81. ]
  82. }
  83. ----