get-category.asciidoc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. When `categorization_field_name` is specified in the job configuration, it is
  24. possible to view the definitions of the resulting categories. A category
  25. definition describes the common terms matched and contains examples of matched
  26. values.
  27. The anomaly results from a categorization analysis are available as bucket,
  28. influencer, and record results. For example, the results might indicate that
  29. at 16:45 there was an unusual count of log message category 11. You can then
  30. examine the description and examples of that category. For more information, see
  31. {ml-docs}/ml-configuring-categories.html[Categorizing log messages].
  32. [[ml-get-category-path-parms]]
  33. ==== {api-path-parms-title}
  34. `<job_id>`::
  35. (Required, string)
  36. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  37. `<category_id>`::
  38. (Optional, long) Identifier for the category. If you do not specify this
  39. parameter, the API returns information about all categories in the {anomaly-job}.
  40. [[ml-get-category-request-body]]
  41. ==== {api-request-body-title}
  42. `page`.`from`::
  43. (Optional, integer) Skips the specified number of categories.
  44. `page`.`size`::
  45. (Optional, integer) Specifies the maximum number of categories to obtain.
  46. [[ml-get-category-results]]
  47. ==== {api-response-body-title}
  48. The API returns an array of category objects, which have the following properties:
  49. `category_id`::
  50. (unsigned integer) A unique identifier for the category.
  51. `examples`::
  52. (array) A list of examples of actual values that matched the category.
  53. `grok_pattern`::
  54. experimental[] (string) A Grok pattern that could be used in {ls} or an ingest
  55. pipeline to extract fields from messages that match the category. This field is
  56. experimental and may be changed or removed in a future release. The Grok
  57. patterns that are found are not optimal, but are often a good starting point for
  58. manual tweaking.
  59. `job_id`::
  60. (string)
  61. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  62. `max_matching_length`::
  63. (unsigned integer) The maximum length of the fields that matched the category.
  64. The value is increased by 10% to enable matching for similar fields that have
  65. not been analyzed.
  66. `regex`::
  67. (string) A regular expression that is used to search for values that match the
  68. category.
  69. `terms`::
  70. (string) A space separated list of the common tokens that are matched in values
  71. of the category.
  72. [[ml-get-category-example]]
  73. ==== {api-examples-title}
  74. [source,console]
  75. --------------------------------------------------
  76. GET _ml/anomaly_detectors/esxi_log/results/categories
  77. {
  78. "page":{
  79. "size": 1
  80. }
  81. }
  82. --------------------------------------------------
  83. // TEST[skip:todo]
  84. [source,js]
  85. ----
  86. {
  87. "count": 11,
  88. "categories": [
  89. {
  90. "job_id" : "esxi_log",
  91. "category_id" : 1,
  92. "terms" : "Vpxa verbose vpxavpxaInvtVm opID VpxaInvtVmChangeListener Guest DiskInfo Changed",
  93. "regex" : ".*?Vpxa.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*",
  94. "max_matching_length": 154,
  95. "examples" : [
  96. "Oct 19 17:04:44 esxi1.acme.com Vpxa: [3CB3FB90 verbose 'vpxavpxaInvtVm' opID=WFU-33d82c31] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  97. "Oct 19 17:04:45 esxi2.acme.com Vpxa: [3CA66B90 verbose 'vpxavpxaInvtVm' opID=WFU-33927856] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  98. "Oct 19 17:04:51 esxi1.acme.com Vpxa: [FFDBAB90 verbose 'vpxavpxaInvtVm' opID=WFU-25e0d447] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  99. "Oct 19 17:04:58 esxi2.acme.com Vpxa: [FFDDBB90 verbose 'vpxavpxaInvtVm' opID=WFU-bbff0134] [VpxaInvtVmChangeListener] Guest DiskInfo Changed"
  100. ],
  101. "grok_pattern" : ".*?%{SYSLOGTIMESTAMP:timestamp}.+?Vpxa.+?%{BASE16NUM:field}.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*"
  102. }
  103. ]
  104. }
  105. ----