get-category.asciidoc 6.1 KB

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