Create an APM anomaly rule

To create APM anomaly rules, you need the following:

Note

Rules use an API key to authorize all background tasks, including condition checks and triggered actions. The key type depends on your deployment. For details on how API keys authorize rules, refer to API keys.

This rule queries the ML anomaly indices and the transaction indices defined in the APM index settings. The default index patterns are .ml-anomalies-* and traces-apm*,apm-*,traces-*.otel-*. You cannot override these indices on a per-rule basis.

You can create an anomaly rule to alert you when either the latency, throughput, or failed transaction rate of a service is unusual. Anomaly rules can be set at different levels: environment, service, and transaction type. Add actions to raise alerts via services or third-party integrations (for example, send an email or create a Jira issue).

From an Applications page, open Alerts in the application menu and select Create anomaly rule. If Alerts is not visible, open the More menu first.

  1. In Definition, select the Service, Type, and Environment, or leave All selected.
  2. Under Detector types, select the anomalies that should trigger alerts. All four types are selected by default: latency, throughput, failed transaction rate, and low transaction count.
  3. Set Has anomaly with severity to the minimum severity to alert on: warning, minor, major, or critical.
  4. Set the rule schedule and click Next.
  5. In Actions, optionally configure notifications or other actions, then continue to Details.
  6. In Details, enter the Rule name and optional Tags, then click Create rule.

These steps show how to use the Alerts UI. You can also create an anomaly rule directly from any page within Applications. Click the Alerts and rules button, and select Create anomaly rule. When you create a rule this way, the Name and Tags fields will be prepopulated but you can still change these.

To create your anomaly rule:

  1. In Observability UI, go to Alerts.
  2. Select Manage Rules from the Alerts page, and select Create rule.
  3. Enter a Name for your rule, and any optional Tags for more granular reporting (leave blank if unsure).
  4. Select the APM Anomaly rule type.
  5. Select the appropriate Service, Type, and Environment (or leave ALL to include all options).
  6. Select the desired severity (critical, major, minor, warning) from Has anomaly with severity.
  7. Define the interval to check the rule (for example, check every 1 minute).
  8. (Optional) Set up Actions.
  9. Save your rule.

Select low transaction count under Detector types to alert when a service's transaction count drops abnormally, including when traffic stops reaching it. This detector is selected by default for new rules. Existing rules retain their saved detector selections, so edit them to include it.

The environment's APM machine learning job must also contain the low_count detector. Selecting it in a rule does not update the job. If the detector is missing, follow Add low-count detection to existing jobs.

You can extend your rules with actions that interact with third-party systems, write to logs or indices, or send user notifications. You can add an action to a rule at any time. You can create rules without adding actions, and you can also define multiple actions for a single rule.

To add actions to rules, you must first create a connector for that service (for example, an email or external incident management system), which you can then use for different rules, each with their own action frequency.