get-category.asciidoc 5.7 KB

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