Kibana: Machine Learning & AIOps

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-09 against Kibana 9.5.x. Tested with Elasticsearch 9.5.6 and Kibana 9.5.6 in the hands-on lab (trial licence): the anomaly detection job and datafeed of this page opened and started on the lab data after the model memory limit was set.

A static threshold needs someone to know the right number. Error logs per five minutes are 3 at night and 40 at noon, and a fixed limit of 20 is wrong twice a day. Machine learning in Kibana learns the normal pattern of a time series, including its daily and weekly cycles, and reports what deviates from it. This page covers the part of the Elastic machine learning features used for monitoring: anomaly detection jobs, their results, the two rules that turn results and job problems into alerts, and the AIOps tools that help find the cause of a change once something is flagged. The ML-based degradation signals that APM and the Infrastructure apps build on top of the same machinery are on APM & Synthetics and Infrastructure & Host Monitoring.

Source: Anomaly detection. Generally available on the Stack and on Serverless.

Requirements and where it runs

Machine learning needs a subscription level that includes it (or an active trial), nodes with the ml role in node.roles and xpack.ml.enabled left at its default of true. In Kibana, full access needs the Machine Learning: All and Data Views Management: All privileges plus read and view_index_metadata on the source indices; read-only access needs Machine Learning: Read. The built-in roles machine_learning_admin and machine_learning_user are Elasticsearch roles for the ML APIs, and they also grant access to the results of all anomaly detection jobs, even for users without access to the source indices. ML features must be visible in the Kibana space, the source data views must exist in the same space as the jobs, and a job can be assigned to one, several or all spaces. Stopping datafeeds or closing jobs needs manage_ml or manage cluster privileges. Roles and spaces in general are on Spaces, Roles & Privileges.

Anomaly detection jobs

A job analyses one time series (or many, split by a field) and models its normal behaviour. The vocabulary:

  • Detector: an analytical function applied to a field, such as count, rare, mean, min, max or sum.

  • Bucket span: the interval used to summarise and model the data, typically 5 minutes to 1 hour. Choose it from the granularity of the analysis, the data frequency, how long an anomaly typically lasts and how quickly you need an alert; Kibana estimates a value and warns when it differs much or exceeds one day.

  • Influencer: a field that contributes to anomalies and is used to rank the entities responsible.

  • Datafeed: the query that feeds the job. A job has one datafeed, which runs at a frequency that defaults from the bucket span; a delay can be added for late data, and aggregations work best with low-cardinality data.

  • Model memory limit: model_memory_limit defaults to 1 GB; above it the model prunes more aggressively and new entities stop being modelled. A limit set too high can stop the job from opening because no node has enough memory.

The Kibana wizards map to job types: Single metric (one detector), Multi-metric (several detectors in one job, more efficient than separate jobs on the same data), Population (activity unusual compared with the rest of a population), Categorization (groups log messages into categories and detects anomalies in them with count or rare) and Advanced (several detectors and every setting). Planning starts from the behaviour you want to detect: temporal deviations in values, counts or frequencies, statistical rarity, unusual locations or unusual behaviour of a population member. A job must be opened before it analyses data, and the datafeed can then be started and stopped. Data stored outside Elasticsearch cannot use the Kibana wizards or datafeeds, and posting data directly to a job is deprecated.

A job for the Bookshelf error logs

The job below counts ERROR log lines per five minutes and flags unusual spikes; it replaces the fixed "20 ERROR lines in 5 minutes" threshold used by the other lab alerts with a learned one. It assumes the Bookshelf JSON logs reach a logs-* data stream with the OTLP level field severity_text (log.level in ECS-shaped logs). Create the job, a datafeed, then open and start them:

PUT _ml/anomaly_detectors/bookshelf-error-rate
{
  "description": "Unusual number of ERROR log lines for the Bookshelf service",
  "analysis_config": {
    "bucket_span": "5m",
    "detectors": [
      { "function": "high_count", "detector_description": "High ERROR log count" }
    ],
    "influencers": ["service.name"]
  },
  "analysis_limits": { "model_memory_limit": "20mb" },
  "data_description": { "time_field": "@timestamp" }
}

PUT _ml/datafeeds/datafeed-bookshelf-error-rate
{
  "job_id": "bookshelf-error-rate",
  "indices": ["logs-*"],
  "query": { "bool": { "filter": [
    { "term": { "severity_text": "ERROR" } },
    { "term": { "service.name": "bookshelf" } }
  ] } }
}

POST _ml/anomaly_detectors/bookshelf-error-rate/_open
POST _ml/datafeeds/datafeed-bookshelf-error-rate/_start

The analysis_limits block is needed in the 2 GB lab: without it Elasticsearch estimates 1 GB for the job, the node offers about 600 MB to machine learning, and _open fails with "no ML nodes with sufficient capacity"; 20 MB is plenty for one count detector. The influencer log.logger of ECS logs does not exist in OTLP logs, so the lab job uses only service.name. The PUT _ml/anomaly_detectors/<job_id> call requires the manage_ml cluster privilege and read on the source indices; analysis_config cannot be changed after creation. The same job is a few clicks in the Advanced wizard.

Reference: Create an anomaly detection job (the datafeed, open and start calls are the neighbouring operations of the same API group).

Reading the results

Results are viewed in two tools. The Anomaly Explorer has an anomaly timeline (the swim lane), an Anomalies table, influencer lists and an Alerts panel that correlates the alert counts of the job’s rules with anomalous buckets. The Single Metric Viewer shows one series against its expected bounds, with the Anomalies table, and is also where forecasts are drawn. Each bucket gets an anomaly score on a 0 to 100 scale that aggregates its records; multi-bucket analysis adjusts it using neighbouring buckets, and anomalies with a medium or high multi-bucket impact are drawn as a cross. Bucket, influencer and record results each have their own scores, so the same moment can show slightly different values in different views. Elastic’s explanation of the scoring labels the bands warning (below 25), minor, major and critical (75 to 100); the APM service map uses a finer legend, so compare against the page you are on. The date picker has zoom buttons, generally available on the Stack since 9.4. The dashboards of Building Dashboards can embed an anomaly swim lane panel, an anomaly chart (a chart from the Anomaly Explorer) and a Single Metric Viewer panel; the Dashboards API also accepts these panels.

Alerting on anomalies

Two rule types, both created under Stack Management then Rules; the Machine Learning app itself creates only the anomaly alert type, from the job wizard or the job list.

Anomaly detection alert rule

Checks the job results for anomalies that meet the conditions:

  • Job selection, and a severity threshold on anomaly_score; the default is 75, and scores at or above it trigger actions.

  • Result type: bucket, record or influencer results. For record and influencer results an anomaly filter (a KQL query on partition or influencer values or on the actual and typical values) is available from Stack 9.3 and on Serverless.

  • Include interim results: alerts on buckets that are not yet finalised. Earlier warnings, with false positives that can disappear later.

  • Lookback interval (default derived from the bucket span and the datafeed query delay; shorter values can miss anomalies) and number of latest buckets (the alert uses the highest-scoring anomaly from the most anomalous bucket).

  • Test: simulates the rule on existing data to show how many alerts it would have fired; set the check interval first, ideally close to the bucket span.

  • Rule scope: from 9.3 the default is All (Infrastructure, Logs, APM, Synthetics and Stack rules).

  • Evaluation of only newly indexed results through event.ingested is described as Planned for the Stack.

Action variables: context.message, context.score, context.timestamp, context.timestampIso8601, context.jobIds, context.isInterim, context.anomalyExplorerUrl, context.topRecords (up to three, with actual, typical, score, function, field_name, partition and by values) and context.topInfluencers (up to three, with the field name, value and score). context.message, context.jobIds and context.anomalyExplorerUrl are also available for recovered alerts.

Anomaly detection jobs health rule

Alerts when an operational problem could stop a job from finding anomalies. Select jobs or groups (a group picks up jobs added later; * covers all jobs, including future ones) and optionally exclude some. Four health checks, all on by default with at least one required:

  • Datafeed not started: a job is open and its datafeed is not running.

  • Model memory limit reached: the soft or hard limit.

  • Data delay occurred: missed documents above a count in a time interval (see the delayed data documentation).

  • Errors in job messages: only errors that occur after the rule was created.

Variables: context.message and context.results, whose properties depend on the check (for example job_id, job_state, datafeed_state, memory_status, missed_docs_count). Run the rule on a schedule close to the bucket span.

Both rules support the standard options: advanced alert delay and flapping detection, summary or per-alert actions, recovery actions, a KQL or time-window refinement of actions and a connector. For the lab the connector is the webhook to http://webhook-receiver:8080/kibana. The model of actions and variables is on Actions, Frequency & Action Variables, the rule families on Rules & Stack Rule Types. An alerting rule on a failing job is the cheapest insurance you can buy: a stopped datafeed looks exactly like a quiet system.

AIOps: finding the cause

AIOps Labs sits in the Machine Learning app (and, for log pattern analysis, in Discover on any text field) and uses statistical methods to explain a change, rather than to detect it:

Tool What it does

Log rate analysis

For a spike or drop in a log event histogram, lists the statistically significant field-value combinations behind it (for example the logger or the endpoint that explains the rise in ERROR lines). Rows can be inspected in Discover, opened in log pattern analysis or copied as a query filter. It is also embedded in other apps.

Log pattern analysis

Categorises the unstructured messages of a selected field with the same algorithm as a categorization job, showing each category’s distribution and an example, with a shortcut to show or filter out a category in Discover.

Change point detection

Uses the change point aggregation to find distribution changes, trend changes and other significant shifts in a metric; choose a function, a metric field and a range, optionally split by a field, with up to six function-and-field combinations (split fields with more than 10,000 values are limited to the top 10,000 by document count). Generally available on the Stack since 9.5 (preview from 9.0 to 9.4) and on Serverless.

The ES|QL route to change points in Discover is documented on Detect change points in Discover.

Source: AIOps Labs.

flowchart LR L["Bookshelf logs and metrics"] --> DF["Datafeed"] DF --> J["Anomaly detection job"] J --> R["Results: buckets, records, influencers"] R --> AE["Anomaly Explorer, Single Metric Viewer, dashboard panels"] R --> AR["Anomaly detection alert rule"] J --> HR["Jobs health rule"] AR --> W["Webhook receiver"] HR --> W AE --> LRA["Log rate analysis and pattern analysis"]

What can go wrong

  • A new job reports nothing for the first hours: it needs time to learn; judge it after at least a few days of data, including one daily cycle.

  • Results stop but no alert fires: the datafeed stopped or the job hit its model memory limit. This is what the jobs health rule is for.

  • The rule misses anomalies because the lookback interval is shorter than the bucket span plus the datafeed delay.

  • Interim results alert early and then disappear: either exclude them or accept the false positives.

  • A job built on a too-granular partition field runs out of model memory; partition on fewer values or raise the limit within what a node can hold.

  • Changes to the roles that the datafeed uses do not apply until the datafeed is updated (send an empty {} update).

  • Alerting on score alone ignores business impact: combine the anomaly rule with a rule on the symptom, and use context.topRecords in the message to say what moved.

  • Metric anomaly jobs of the Infrastructure UI and the APM jobs exist per resource type or environment; do not duplicate them with an advanced job unless you need a different bucket span.

Verify it in the lab

  1. With the kibana profile and the load generator running for at least 30 minutes, create the bookshelf-error-rate job, its datafeed and open and start them (the requests above, in Dev Tools).

  2. In Machine Learning then Anomaly Detection then Jobs, check that the job is opened and the datafeed started, then open the Single Metric Viewer: the model bounds must appear around the error count.

  3. Switch the load generator to failing-request mode for 10 minutes. After the next buckets the Anomaly Explorer must show a highlighted bucket, and the Anomalies table must list the actual count above the typical one.

  4. Create the anomaly detection alert rule for the job (severity threshold 75, result type bucket, check interval 5 minutes) with a webhook action to http://webhook-receiver:8080/kibana, and the jobs health rule with all four checks. Stop the datafeed: the health rule must notify after its next check; start it again and check the recovery.

  5. Open AIOps Labs then Log rate analysis, pick the Bookshelf log data view and select the error spike: the field-value table should point at the failing route or the logger that explains it.

In the books

Shah, Kibana 8.x Quick Start Guide, chapter 6, introduces anomaly detection on the e-commerce sample data: detectors, models and influencers, the single metric, multi-metric, population and categorization wizards, the Single Metric Viewer and Anomaly Explorer, entity-centric analysis with transforms, data frame analytics, calendars and forecasts, and setting up an anomaly detection alert from Stack Management. The concepts are unchanged. The book targets the Kibana 8.11 and 8.12 interface, so the current alert rules (with the anomaly filter since 9.3 and the jobs health rule), the AIOps tools including change point detection (generally available in 9.5) and the dashboard panels are newer than the book. Publisher pages are listed in the bibliography of the section index.