Kibana Guide: Anomaly Detection and 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-11 against Kibana 9.5.x.

What you build

You use the Machine Learning tools of Kibana on the Bookshelf logs. A single metric job, guide-bookshelf-log-rate, learns the normal number of log lines per minute and flags buckets that differ from it. You read its results, run a forecast, and then use log rate analysis to explain a spike of the failing mode: the analysis lists the field values behind the extra log lines, here the ERROR level and the status 500. A change point detection run finds the moment when the average status code moved. The picture shows the end of the log rate analysis, the table of field values that explain the deviation.

Log rate analysis page of Kibana 9.5 after Run analysis, drawn generically: the chart with the Baseline and Deviation areas, the status Analysis complete, the Smart grouping switch, the Fields and Columns tabs and a table listing severity_text ERROR and attributes.status 500 as the field values behind the spike

Before you start

  • Start the Kibana profile of the hands-on lab and wait about a minute:

    cd lab
    docker compose --profile kibana up -d
  • Open http://localhost:5601 and sign in as elastic with the password lab-elastic-password. When Kibana opens its full-screen welcome page, click Explore on my own.

  • Do the previous guide, Manage alerts, maintenance windows and cases, and the guide that creates the data view, Upload a file and create a data view. This guide needs the data view Bookshelf logs (guides).

  • Licence: anomaly detection and forecasts need a Platinum licence, which the trial licence of the lab includes. Check it with curl -s -u elastic:lab-elastic-password http://localhost:9200/_license. Log rate analysis, change point detection and the Data Visualizer are listed on the Machine Learning overview of the trial licence.

  • Memory: the lab runs Elasticsearch with a small heap. If the job does not open and Kibana reports that no machine learning node has enough capacity, lower the model memory limit of the job, as the reference page on machine learning explains.

  • The load generator gives the data: the default mode fills the log data stream, failing adds ERROR lines and stop pauses the traffic.

  • Not run end to end: the Data Visualizer page, the single metric wizard, the Single Metric Viewer, the forecast, the Anomaly Explorer and change point detection were not completed in the lab. Their figures are drawn generically from the Elastic documentation, and the steps name the control without promising its exact place. The Machine Learning overview and the log rate analysis page were opened in the lab. In that run the automatically selected deviation of log rate analysis returned no results, so this guide has you select the deviation yourself.

  • A model needs history. A job started on a lab that has run for minutes may flag nothing yet; the check section says what to do then.

  • The figures are drawings of the Kibana 9.5 user interface, not screenshots, so small details can differ from your screen. A highlighted box with a number marks the control of the step with the same number.

Steps

One screen is the starting point of every tool: the Machine Learning Overview, with the sections Analyze your data, Surface insights and Visualize your data. Come back to it with the menu button and Machine Learning whenever a step says to open a tool.

Look at the data in the Data Visualizer

  1. Click the menu button (Toggle primary navigation) at the left of the second bar and, under Analytics, click Machine Learning.

  2. Under Visualize your data, in the card Data view, click Open data visualizer.

    Machine Learning overview of Kibana 9.5 with the sections Analyze your data, Surface insights and Visualize your data and their cards; the menu button of the second bar is marked by callout 1 and the Open data visualizer button of the Data view card by callout 2
  3. Choose the data view Bookshelf logs (guides). If the page first asks for a data view, pick it there.

  4. Find the row of the field severity_text and read its values, INFO and ERROR. This is the field the log rate analysis explains later.

    Data Visualizer of Kibana 9.5, drawn generically, on the data view Bookshelf logs (guides): the data view picker is marked by callout 3 and the row of the field severity_text, with its two values INFO and ERROR, by callout 4

Create a single metric job

  1. Go back to the Overview and, in the card Anomaly detection, click Create anomaly detection job.

  2. Choose the data view Bookshelf logs (guides).

    Create job page of the anomaly detection wizard in Kibana 9.5, drawn generically, with a list of data views; Bookshelf logs (guides) is marked by callout 6
  3. Choose the job type Single metric, which analyses one time series.

    Job type page of the anomaly detection wizard in Kibana 9.5, drawn generically, with six cards: Single metric, Multi-metric, Population, Advanced, Categorization and Rare; the Single metric card is marked by callout 7
  4. In the first wizard step, Time range, click Use full data.

  5. Click Next.

    Time range step of the single metric wizard in Kibana 9.5, drawn generically: the Use full data button is marked by callout 8 and the Next button by callout 9; a chart of the document count of Bookshelf logs (guides) shows the data range
  6. In Pick fields, choose the aggregation Count, so that the job models the number of log lines in each bucket.

  7. Set the Bucket span to 1m.

  8. Click Next.

    Pick fields step of the single metric wizard in Kibana 9.5, drawn generically: the aggregation Count is marked by callout 10, the bucket span 1m by callout 11 and the Next button by callout 12; the chart previews the document count
  9. In Job details, type the Job ID guide-bookshelf-log-rate.

  10. Click Next to go through the Validation step and read its messages.

    Job details step of the single metric wizard in Kibana 9.5, drawn generically: the Job ID guide-bookshelf-log-rate is marked by callout 13 and the Next button, which leads to the Validation step, by callout 14
  11. In Summary, click Create job. If the wizard offers to keep the job running in real time, choose that, so that the job also analyses the traffic you send in the check section.

Read the results and run a forecast

  1. Open the job in the Single Metric Viewer, from the list of jobs under Machine Learning → Anomaly Detection → Jobs or from the wizard when it offers the results.

  2. Read the chart: the line is the actual count per bucket, the shaded band is what the model expects, and a coloured marker flags a bucket as an anomaly. The table Anomalies below it lists time, severity, actual and typical values.

    Single Metric Viewer of Kibana 9.5, drawn generically, for the job guide-bookshelf-log-rate: the actual document count, the shaded expected bounds and two red anomaly markers are marked by callout 17; an Anomalies table lists their time, severity, actual and typical values
  3. Click Forecast.

  4. In the dialog that opens, set the duration to 1d.

  5. Click Run. The forecast is drawn after the actual line, with its own expected band.

    Single Metric Viewer of Kibana 9.5 with a forecast dialog drawn generically: the Forecast button is marked by callout 18, the duration 1d by callout 19 and the Run button by callout 20
  6. Open the same job in the Anomaly Explorer.

  7. In the anomaly timeline, click a coloured cell of the Overall lane. Cells are coloured by the severity of the anomalies of that period.

  8. Read the table Anomalies below the timeline, which now lists the anomalies of the selected period.

    Anomaly Explorer of Kibana 9.5, drawn generically, with the anomaly timeline: three coloured cells of the Overall lane are marked by callout 22 and the Anomalies table below them by callout 23

Explain a spike with log rate analysis

Log rate analysis explains a change after it happened. It needs the failing period in the data, and it works best when the traffic has returned to normal, so that the chart shows a baseline and a deviation.

  1. In a terminal, start the failing mode and wait about three minutes:

    curl -X POST localhost:8090/mode/failing
  2. Restore normal traffic:

    curl -X POST localhost:8090/mode/normal
  3. Open the Overview and, in the card Log rate analysis, click Explain changes.

  4. Choose the data view Bookshelf logs (guides) in the picker and set the time picker to Last 30 minutes, so that the chart shows the failing period.

    Log rate analysis page of Kibana 9.5 on the data view Bookshelf logs (guides) with a bar chart of the documents per interval, the banner Log rate change point detected and the Run analysis button; the data view picker and the time picker Last 30 minutes are marked by callout 27
  5. Select the deviation in the chart, the bars of the failing period. Do not rely on the window that Kibana selects automatically: in the lab it was taken after the failing period and found nothing. When the selection works, the chart shows the areas Baseline and Deviation.

  6. Click Run analysis.

    Log rate analysis page of Kibana 9.5 with the failing period selected in the chart, drawn with a dashed Deviation area over the high bars and a dashed Baseline area before them; the Deviation area is marked by callout 28 and the Run analysis button by callout 29
  7. When the status says Analysis complete, read the table of the tab Fields, as in the figure under What you build. It lists the field values that explain the extra log lines; the candidate fields are severity_text, attributes.uri, attributes.status and body.text. Turn on Smart grouping to merge values that always appear together, and use Reset to start again.

Find a change point

  1. Go back to the Overview and, in the card Change point detection, click Find changes.

  2. Choose the data view Bookshelf logs (guides).

  3. Choose the function avg.

  4. Choose the metric field attributes.status. The average status code moves when the failing mode returns 500 answers, and the result lists the moment of the change.

    Change point detection page of Kibana 9.5, drawn generically: the data view Bookshelf logs (guides) is marked by callout 32, the function avg by callout 33 and the metric field attributes.status by callout 34; the chart shows a step up of the average and a table lists one step change

Check the result

  • Log rate analysis: the table of the tab Fields must list severity_text with the value ERROR and, if the failing mode answered with 500, attributes.status with the value 500. The drawing under What you build shows the layout, not your values.

  • Change point detection: the chart for avg of attributes.status must show a change in the failing period.

  • Anomaly detection: pause the traffic and bring it back, so that the job sees an unusual number of log lines, then reopen the Single Metric Viewer after a few minutes:

    curl -X POST localhost:8090/mode/stop

    Wait about four minutes, then restore the traffic:

    curl -X POST localhost:8090/mode/normal

    The paused buckets are far below the learned count and should be flagged. If the Anomaly Explorer shows no coloured cell, the model has too little history: let the lab and the job run for an hour and repeat the pause. This check was not run end to end in the lab.

Variations

  • Run the job as a multi-metric or a population job, or split the count by attributes.uri, to model each URI separately.

  • Create an anomaly detection alert rule for the job from Stack Management → Rules; the reference page on machine learning describes the rule and its connector.

  • Run log pattern analysis from the Overview with Find patterns on the field body.text to group the log messages.

What can go wrong

Symptom Cause Fix

Log rate analysis says that the analysis did not return any results

The automatically selected deviation does not cover the failing period.

Select the deviation yourself in the chart, over the bars of the failing period, and run the analysis again.

The chart of log rate analysis shows no spike

The time picker does not cover the failing period, or the failing mode ran for less than a minute.

Set Last 30 minutes or Last 1 hour, run the failing mode for about three minutes and restore it with curl -X POST localhost:8090/mode/normal.

The job does not open

The node has too little memory for the default model memory limit.

Lower the model memory limit in the job settings and reopen the job.

The Anomaly Explorer shows no anomalies

The model has seen too little data to know what is normal.

Let the job run longer, then pause the traffic again as in the check section.

The machine learning pages ask for a licence

The licence is not Platinum or trial.

Check the licence with curl -s -u elastic:lab-elastic-password http://localhost:9200/_license; the lab starts a trial licence.

Clean up

Keep the job if you want to look at it again. To remove it, open it in Machine Learning → Anomaly Detection → Jobs, stop its datafeed, close it and delete it. Forecasts are deleted with the job. Stopping the profile with docker compose --profile kibana down -v deletes everything the lab stores.

Where to go next