ml-configuring-alerts.asciidoc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. [role="xpack"]
  2. [[ml-configuring-alerts]]
  3. = Generating alerts for {anomaly-jobs}
  4. beta::[]
  5. {kib} {alert-features} include support for {ml} rules, which run scheduled
  6. checks for anomalies in one or more {anomaly-jobs} or check the health of the
  7. job with certain conditions. If the conditions of the rule are met, an alert is
  8. created and the associated action is triggered. For example, you can create a
  9. rule to check an {anomaly-job} every fifteen minutes for critical anomalies and
  10. to notify you in an email. To learn more about {kib} {alert-features}, refer to
  11. {kibana-ref}/alerting-getting-started.html#alerting-getting-started[Alerting].
  12. The following {ml} rules are available:
  13. {anomaly-detect-cap} alert::
  14. Checks if the {anomaly-job} results contain anomalies that match the rule
  15. conditions.
  16. {anomaly-jobs-cap} health::
  17. Monitors job health and alerts if an operational issue occurred that may
  18. prevent the job from detecting anomalies.
  19. TIP: If you have created rules for specific {anomaly-jobs} and you want to
  20. monitor whether these jobs work as expected, {anomaly-jobs} health rules are
  21. ideal for this purpose.
  22. [[creating-ml-rules]]
  23. == Creating a rule
  24. You can create {ml} rules in the {anomaly-job} wizard after you start the job,
  25. from the job list, or under **{stack-manage-app} > {alerts-ui}**.
  26. On the *Create rule* window, give a name to the rule and optionally provide
  27. tags. Specify the time interval for the rule to check detected anomalies or job
  28. health changes. It is recommended to select an interval that is close to the
  29. bucket span of the job. You can also select a notification option with the
  30. _Notify_ selector. An alert remains active as long as the configured conditions
  31. are met during the check interval. When there is no matching condition in the
  32. next interval, the `Recovered` action group is invoked and the status of the
  33. alert changes to `OK`. For more details, refer to the documentation of
  34. {kibana-ref}/create-and-manage-rules.html#defining-rules-general-details[general rule details].
  35. Select the rule type you want to create under the {ml} section and continue to
  36. configure it depending on whether it is an
  37. <<creating-anomaly-alert-rules, {anomaly-detect} alert>> or an
  38. <<creating-anomaly-jobs-health-rules, {anomaly-job} health>> rule.
  39. [role="screenshot"]
  40. image::images/ml-rule.jpg["Creating a new machine learning rule"]
  41. [[creating-anomaly-alert-rules]]
  42. === {anomaly-detect-cap} alert
  43. Select the job that the rule applies to.
  44. You must select a type of {ml} result. In particular, you can create rules based
  45. on bucket, record, or influencer results.
  46. [role="screenshot"]
  47. image::images/ml-anomaly-alert-severity.jpg["Selecting result type, severity, and test interval"]
  48. For each rule, you can configure the `anomaly_score` that triggers the action.
  49. The `anomaly_score` indicates the significance of a given anomaly compared to
  50. previous anomalies. The default severity threshold is 75 which means every
  51. anomaly with an `anomaly_score` of 75 or higher triggers the associated action.
  52. You can select whether you want to include interim results. Interim results are
  53. created by the {anomaly-job} before a bucket is finalized. These results might
  54. disappear after the bucket is fully processed. Include interim results if you
  55. want to be notified earlier about a potential anomaly even if it might be a
  56. false positive. If you want to get notified only about anomalies of fully
  57. processed buckets, do not include interim results.
  58. You can also configure advanced settings. _Lookback interval_ sets an interval
  59. that is used to query previous anomalies during each condition check. Its value
  60. is derived from the bucket span of the job and the query delay of the {dfeed} by
  61. default. It is not recommended to set the lookback interval lower than the
  62. default value as it might result in missed anomalies. _Number of latest buckets_
  63. sets how many buckets to check to obtain the highest anomaly from all the
  64. anomalies that are found during the _Lookback interval_. An alert is created
  65. based on the anomaly with the highest anomaly score from the most anomalous
  66. bucket.
  67. You can also test the configured conditions against your existing data and check
  68. the sample results by providing a valid interval for your data. The generated
  69. preview contains the number of potentially created alerts during the relative
  70. time range you defined.
  71. As the last step in the rule creation process,
  72. <<defining-actions, define the actions>> that occur when the conditions
  73. are met.
  74. [[creating-anomaly-jobs-health-rules]]
  75. === {anomaly-jobs-cap} health
  76. Select the job or group that the rule applies to. If you assign more jobs to the
  77. group, they are included the next time the rule conditions are checked.
  78. You can also use a special character (`*`) to apply the rule to all your jobs.
  79. Jobs created after the rule are automatically included. You can exclude jobs
  80. that are not critically important by using the _Exclude_ field.
  81. Enable the health check types that you want to apply. All checks are enabled by
  82. default. At least one check needs to be enabled to create the rule. The
  83. following health checks are available:
  84. _Datafeed is not started_::
  85. Notifies if the corresponding {dfeed} of the job is not started but the job is
  86. in an opened state. The notification message recommends the necessary
  87. actions to solve the error.
  88. _Model memory limit reached_::
  89. Notifies if the model memory status of the job reaches the soft or hard model
  90. memory limit. Optimize your job by following
  91. <<detector-configuration, these guidelines>> or consider
  92. <<set-model-memory-limit, amending the model memory limit>>.
  93. _Data delay has occurred_::
  94. Notifies when the job missed some data. You can define the threshold for the
  95. amount of missing documents you get alerted on by setting
  96. _Number of documents_. You can control the lookback interval for checking
  97. delayed data with _Time interval_. Refer to the
  98. <<ml-delayed-data-detection>> page to see what to do about delayed data.
  99. _Errors in job messages_::
  100. Notifies when the job messages contain error messages. Review the
  101. notification; it contains the error messages, the corresponding job IDs and
  102. recommendations on how to fix the issue. This check looks for job errors
  103. that occur after the rule is created; it does not look at historic behavior.
  104. [role="screenshot"]
  105. image::images/ml-health-check-config.jpg["Selecting health checkers"]
  106. As the last step in the rule creation process,
  107. <<defining-actions, define the actions>> that occur when the conditions
  108. are met.
  109. [[defining-actions]]
  110. == Defining actions
  111. Connect your rule to actions that use supported built-in integrations by
  112. selecting a connector type. Connectors are {kib} services or third-party
  113. integrations that perform an action when the rule conditions are met or the
  114. alert is recovered. You can select in which case the action will run.
  115. [role="screenshot"]
  116. image::images/ml-anomaly-alert-actions.jpg["Selecting connector type"]
  117. For example, you can choose _Slack_ as a connector type and configure it to send
  118. a message to a channel you selected. You can also create an index connector that
  119. writes the JSON object you configure to a specific index. It's also possible to
  120. customize the notification messages. A list of variables is available to include
  121. in the message, like job ID, anomaly score, time, top influencers, {dfeed} ID,
  122. memory status and so on based on the selected rule type. Refer to
  123. <<action-variables>> to see the full list of available variables by rule type.
  124. [role="screenshot"]
  125. image::images/ml-anomaly-alert-messages.jpg["Customizing your message"]
  126. After you save the configurations, the rule appears in the *{alerts-ui}* list
  127. where you can check its status and see the overview of its configuration
  128. information.
  129. The name of an alert is always the same as the job ID of the associated
  130. {anomaly-job} that triggered it. You can mute the notifications for a particular
  131. {anomaly-job} on the page of the rule that lists the individual alerts. You can
  132. open it via *{alerts-ui}* by selecting the rule name.
  133. [[action-variables]]
  134. == Action variables
  135. You can add different variables to your action. The following variables are
  136. specific to the {ml} rule types. An `*` marks the variables that can be used for
  137. actions of recovered alerts.
  138. [[anomaly-alert-action-variables]]
  139. === {anomaly-detect-cap} alert action variables
  140. Every {anomaly-detect} alert has the following action variables:
  141. `context`.`anomalyExplorerUrl` ^*^::
  142. URL to open in the Anomaly Explorer.
  143. `context`.`isInterim`::
  144. Indicates if top hits contain interim results.
  145. `context`.`jobIds` ^*^::
  146. List of job IDs that triggered the alert.
  147. `context`.`message` ^*^::
  148. A preconstructed message for the alert.
  149. `context`.`score`::
  150. Anomaly score at the time of the notification action.
  151. `context`.`timestamp`::
  152. The bucket timestamp of the anomaly.
  153. `context`.`timestampIso8601`::
  154. The bucket timestamp of the anomaly in ISO8601 format.
  155. `context`.`topInfluencers`::
  156. The list of top influencers.
  157. +
  158. .Properties of `context.topInfluencers`
  159. [%collapsible%open]
  160. ====
  161. `influencer_field_name`:::
  162. The field name of the influencer.
  163. `influencer_field_value`:::
  164. The entity that influenced, contributed to, or was to blame for the anomaly.
  165. `score`:::
  166. The influencer score. A normalized score between 0-100 which shows the
  167. influencer's overall contribution to the anomalies.
  168. ====
  169. `context`.`topRecords`::
  170. The list of top records.
  171. +
  172. .Properties of `context.topRecords`
  173. [%collapsible%open]
  174. ====
  175. `actual`:::
  176. The actual value for the bucket.
  177. `by_field_value`:::
  178. The value of the by field.
  179. `field_name`:::
  180. Certain functions require a field to operate on, for example, `sum()`. For those
  181. functions, this value is the name of the field to be analyzed.
  182. `function`:::
  183. The function in which the anomaly occurs, as specified in the detector
  184. configuration. For example, `max`.
  185. `over_field_name`:::
  186. The field used to split the data.
  187. `partition_field_value`:::
  188. The field used to segment the analysis.
  189. `score`:::
  190. A normalized score between 0-100, which is based on the probability of the
  191. anomalousness of this record.
  192. `typical`:::
  193. The typical value for the bucket, according to analytical modeling.
  194. ====
  195. [[anomaly-jobs-health-action-variables]]
  196. === {anomaly-jobs-cap} health action variables
  197. Every health check has two main variables: `context.message` and
  198. `context.results`. The properties of `context.results` may vary based on the
  199. type of check. You can find the possible properties for all the checks below.
  200. ==== _Datafeed is not started_
  201. `context.message` ^*^::
  202. A preconstructed message for the alert.
  203. `context.results`::
  204. Contains the following properties:
  205. +
  206. .Properties of `context.results`
  207. [%collapsible%open]
  208. ====
  209. `datafeed_id` ^*^:::
  210. The {dfeed} identifier.
  211. `datafeed_state` ^*^:::
  212. The state of the {dfeed}. It can be `starting`, `started`,
  213. `stopping`, `stopped`.
  214. `job_id` ^*^:::
  215. The job identifier.
  216. `job_state` ^*^:::
  217. The state of the job. It can be `opening`, `opened`, `closing`,
  218. `closed`, or `failed`.
  219. ====
  220. ==== _Model memory limit reached_
  221. `context.message` ^*^::
  222. A preconstructed message for the rule.
  223. `context.results`::
  224. Contains the following properties:
  225. +
  226. .Properties of `context.results`
  227. [%collapsible%open]
  228. ====
  229. `job_id` ^*^:::
  230. The job identifier.
  231. `memory_status` ^*^:::
  232. The status of the mathematical model. It can have one of the following values:
  233. * `soft_limit`: The model used more than 60% of the configured memory limit and
  234. older unused models will be pruned to free up space. In categorization jobs no
  235. further category examples will be stored.
  236. * `hard_limit`: The model used more space than the configured memory limit. As a
  237. result, not all incoming data was processed.
  238. The `memory_status` is `ok` for recovered alerts.
  239. `model_bytes` ^*^:::
  240. The number of bytes of memory used by the models.
  241. `model_bytes_exceeded` ^*^:::
  242. The number of bytes over the high limit for memory usage at the last allocation
  243. failure.
  244. `model_bytes_memory_limit` ^*^:::
  245. The upper limit for model memory usage.
  246. `log_time` ^*^:::
  247. The timestamp of the model size statistics according to server time. Time
  248. formatting is based on the {kib} settings.
  249. `peak_model_bytes` ^*^:::
  250. The peak number of bytes of memory ever used by the model.
  251. ====
  252. ==== _Data delay has occurred_
  253. `context.message` ^*^::
  254. A preconstructed message for the rule.
  255. `context.results`::
  256. For recovered alerts, `context.results` is either empty (when there is no
  257. delayed data) or the same as for an active alert (when the number of missing
  258. documents is less than the _Number of documents_ treshold set by the user).
  259. Contains the following properties:
  260. +
  261. .Properties of `context.results`
  262. [%collapsible%open]
  263. ====
  264. `annotation` ^*^:::
  265. The annotation corresponding to the data delay in the job.
  266. `end_timestamp` ^*^:::
  267. Timestamp of the latest finalized buckets with missing documents. Time
  268. formatting is based on the {kib} settings.
  269. `job_id` ^*^:::
  270. The job identifier.
  271. `missed_docs_count` ^*^:::
  272. The number of missed documents.
  273. ====
  274. ==== _Error in job messages_
  275. `context.message` ^*^::
  276. A preconstructed message for the rule.
  277. `context.results`::
  278. Contains the following properties:
  279. +
  280. .Properties of `context.results`
  281. [%collapsible%open]
  282. ====
  283. `timestamp`:::
  284. Timestamp of the latest finalized buckets with missing documents.
  285. `job_id`:::
  286. The job identifier.
  287. `message`:::
  288. The error message.
  289. `node_name`:::
  290. The name of the node that runs the job.
  291. ====