get-category.asciidoc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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>>, <<built-in-roles>>, and
  20. {ml-docs-setup-privileges}.
  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::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  37. `<category_id>`::
  38. (Optional, long) Identifier for the category, which is unique in the job. If you
  39. specify neither the category ID nor the `partition_field_value`, the API returns
  40. information about all categories. If you specify only the
  41. `partition_field_value`, it returns information about all categories for the
  42. specified partition.
  43. [[ml-get-category-request-body]]
  44. == {api-request-body-title}
  45. `page`.`from`::
  46. (Optional, integer) Skips the specified number of categories.
  47. `page`.`size`::
  48. (Optional, integer) Specifies the maximum number of categories to obtain.
  49. `partition_field_value`::
  50. (Optional, string) Only return categories for the specified partition.
  51. [[ml-get-category-results]]
  52. == {api-response-body-title}
  53. The API returns an array of category objects, which have the following properties:
  54. `category_id`::
  55. (unsigned integer) A unique identifier for the category. `category_id` is unique
  56. at the job level, even when per-partition categorization is enabled.
  57. `examples`::
  58. (array) A list of examples of actual values that matched the category.
  59. `grok_pattern`::
  60. experimental[] (string) A Grok pattern that could be used in {ls} or an ingest
  61. pipeline to extract fields from messages that match the category. This field is
  62. experimental and may be changed or removed in a future release. The Grok
  63. patterns that are found are not optimal, but are often a good starting point for
  64. manual tweaking.
  65. `job_id`::
  66. (string)
  67. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  68. `max_matching_length`::
  69. (unsigned integer) The maximum length of the fields that matched the category.
  70. The value is increased by 10% to enable matching for similar fields that have
  71. not been analyzed.
  72. // This doesn't use the shared description because there are
  73. // categorization-specific aspects to its use in this context
  74. `partition_field_name`::
  75. (string) If per-partition categorization is enabled, this property identifies
  76. the field used to segment the categorization. It is not present when
  77. per-partition categorization is disabled.
  78. `partition_field_value`::
  79. (string) If per-partition categorization is enabled, this property identifies
  80. the value of the `partition_field_name` for the category. It is not present when
  81. per-partition categorization is disabled.
  82. `regex`::
  83. (string) A regular expression that is used to search for values that match the
  84. category.
  85. `terms`::
  86. (string) A space separated list of the common tokens that are matched in values
  87. of the category.
  88. `num_matches`::
  89. (long) The number of messages that have been matched by this category. This is
  90. only guaranteed to have the latest accurate count after a job `_flush` or `_close`
  91. `preferred_to_categories`::
  92. (list) A list of `category_id` entries that this current category encompasses.
  93. Any new message that is processed by the categorizer will match against this
  94. category and not any of the categories in this list. This is only guaranteed
  95. to have the latest accurate list of categories after a job `_flush` or `_close`
  96. [[ml-get-category-example]]
  97. == {api-examples-title}
  98. [source,console]
  99. --------------------------------------------------
  100. GET _ml/anomaly_detectors/esxi_log/results/categories
  101. {
  102. "page":{
  103. "size": 1
  104. }
  105. }
  106. --------------------------------------------------
  107. // TEST[skip:todo]
  108. [source,js]
  109. ----
  110. {
  111. "count": 11,
  112. "categories": [
  113. {
  114. "job_id" : "esxi_log",
  115. "category_id" : 1,
  116. "terms" : "Vpxa verbose vpxavpxaInvtVm opID VpxaInvtVmChangeListener Guest DiskInfo Changed",
  117. "regex" : ".*?Vpxa.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*",
  118. "max_matching_length": 154,
  119. "examples" : [
  120. "Oct 19 17:04:44 esxi1.acme.com Vpxa: [3CB3FB90 verbose 'vpxavpxaInvtVm' opID=WFU-33d82c31] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  121. "Oct 19 17:04:45 esxi2.acme.com Vpxa: [3CA66B90 verbose 'vpxavpxaInvtVm' opID=WFU-33927856] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  122. "Oct 19 17:04:51 esxi1.acme.com Vpxa: [FFDBAB90 verbose 'vpxavpxaInvtVm' opID=WFU-25e0d447] [VpxaInvtVmChangeListener] Guest DiskInfo Changed",
  123. "Oct 19 17:04:58 esxi2.acme.com Vpxa: [FFDDBB90 verbose 'vpxavpxaInvtVm' opID=WFU-bbff0134] [VpxaInvtVmChangeListener] Guest DiskInfo Changed"
  124. ],
  125. "grok_pattern" : ".*?%{SYSLOGTIMESTAMP:timestamp}.+?Vpxa.+?%{BASE16NUM:field}.+?verbose.+?vpxavpxaInvtVm.+?opID.+?VpxaInvtVmChangeListener.+?Guest.+?DiskInfo.+?Changed.*"
  126. }
  127. ]
  128. }
  129. ----