Kibana Guide: Create a Rule with a Connector

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 create two connectors and one rule. The webhook connector guide-webhook posts to the lab’s webhook receiver and the connector guide-server-log writes to the Kibana log. The rule Guide Bookshelf error logs is an Elasticsearch query rule: it runs every minute, counts the Bookshelf log records with severity_text : "ERROR" of the last minute and raises an alert when there are more than five. Its action sends the rule name, the alert, the document count and the condition to the receiver when the alert becomes active, and a second action tells the receiver when the alert recovers. You force the failure with the load generator, read the alert in Kibana and read the payload at the receiver. The figure shows the end of the story: the alert of the rule, Recovered after traffic returned to normal.

Alerts page of Observability with the alert of the rule Guide Bookshelf error logs in the status Recovered, after the load generator returned to normal traffic

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 guide Upload a file and create a data view, which creates the data view Bookshelf logs (guides) (index pattern logs-generic.otel-default, time field @timestamp), and let the load generator run for a couple of minutes. The previous guide in the series is Share, export and move dashboards; this guide does not depend on it.

  • The webhook connector and the alert actions need a licence above the basic one; the lab starts a trial licence, which is enough. The user elastic has every privilege the guide needs.

  • The webhook receiver of the lab listens on port 8081 of the host and on port 8080 inside the Docker network. The connector of this guide uses its own path, /guide-kibana, so that its deliveries are easy to tell from the ones of the lab’s provisioned rules.

  • The guide was checked on Elasticsearch and Kibana 9.5.6. The Connectors and Rules pages, the connector forms, the rule form with its three steps, the alerts page and the alert flyout were read in the lab, and a rule with the settings of this guide was created there through the API and forced to fire; the connector form, the rule form and the action form were then replayed click by click. The Server log form and the exact wrapping of the action body editor are drawn from the Elastic documentation, so look for a control by its name when it is not where a figure shows it. 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

The rule form of Kibana 9.5 is a page, not a flyout, and it has three steps on one page: Definition, Actions and Details. The map shows the page and its regions; come back to it when a control is not where a figure shows it.

Map of the Kibana 9.5 Create rule page for an Elasticsearch query rule: the rule name, the three steps Definition, Actions and Details, the schedule and advanced options, and the buttons at the bottom

Create the connectors

  1. Open the primary navigation (Toggle primary navigation) and, under Management, click Stack Management.

  2. In the left menu, under Alerts and Insights, click Connectors.

  3. Click Create connector.

    Stack Management with the Connectors page, empty: the entry Connectors under Alerts and Insights in the left menu is marked by callout 2 and the Create connector button of the page header by callout 3
  4. In the flyout Select a connector, click Webhook.

    The Select a connector flyout over the Connectors page with cards for Email, Index, Server log, Slack, Webhook and AWS Lambda; the card Webhook is marked by callout 4
  5. In Connector name, type guide-webhook.

  6. In URL, type the address of the lab’s receiver inside the Docker network. The form rejects a host name without a dot (it says URL is invalid for webhook-receiver), so the lab gives the receiver the extra network name webhook.lab. Leave Method on POST, and under Authentication choose None, because the form starts on Basic authentication.

    http://webhook.lab:8080/guide-kibana
  7. Turn on the switch Add HTTP header, and in the HTTP headers row that appears enter the key Content-Type and the value application/json.

  8. Click Save.

    The Webhook connector form with the connector name guide-webhook (callout 5), the method POST and the URL http://webhook.lab:8080/guide-kibana (callout 6), authentication None, the HTTP header Content-Type with the value application/json (callout 7) and the Save button (callout 8)
  9. Click Create connector again, click Server log, type guide-server-log as the name and click Save.

Define the rule

  1. In the left menu of Stack Management, under Alerts and Insights, click Rules.

  2. Click Create rule.

    Stack Management with the Rules page: the entry Rules under Alerts and Insights in the left menu is marked by callout 10 and the Create rule button of the page header by callout 11
  3. In the flyout Create new rule, stay on the tab Rule type and click the card Elasticsearch query ("Alert when matches are found during the latest query run.").

    The Create new rule flyout over the Rules page with the tabs Rule type and Template, the category list and the cards Elasticsearch query, Index threshold and Custom threshold; the card Elasticsearch query is marked by callout 12
  4. In step 1 Definition, under Select a query type, choose KQL or Lucene.

  5. In Select a data view, choose Bookshelf logs (guides). The picker starts on the default data view of Kibana, which is another one.

  6. In the query box under Define your query, type the KQL query of the error log records:

    severity_text : "ERROR"
  7. Under Set the group, threshold, and time window, change the threshold so that the sentence reads IS ABOVE 5.

  8. Change the time window so that the sentence reads FOR THE LAST 1 minute. The sentence now reads: WHEN count() OVER all documents IS ABOVE 5 FOR THE LAST 1 minute. Leave SIZE at 100 and Exclude matches from previous runs as it is.

  9. Click Test query. Kibana runs the query once and reports how many documents match; with normal traffic the count is small.

    Step 1 Definition of the Elasticsearch query rule: the query type KQL or Lucene (callout 13), the data view Bookshelf logs (guides) (callout 14), the query severity_text equal to ERROR (callout 15), the condition WHEN count() OVER all documents IS ABOVE 5 (callout 16) FOR THE LAST 1 minute (callout 17), and the Test query button (callout 18)
  10. In Rule schedule, set Every to 1 and the unit to minute.

    Rule schedule of the Elasticsearch query rule with the frequency Every 1 minute marked by callout 19, above the collapsed Advanced options with Alert delay and Alert flapping detection

Add the actions

  1. In step 2 Actions, click Add action. The flyout Select connector opens.

  2. Click the connector guide-webhook.

    Step 2 Actions of the rule page with the Add action button marked by callout 20 and the Select connector flyout listing guide-server-log, guide-webhook, Cases and Workflows; the connector guide-webhook is marked by callout 21
  3. In Run when, keep Query matched.

  4. In Action frequency, keep For each alert and select On status changes, so that the webhook is called once when the alert becomes active and not at every check.

  5. In the body of the action, which is sent with an HTTP POST, type this JSON. The variables in double braces are filled in by Kibana when the action runs:

    {"rule":"{{rule.name}}","alert":"{{alert.id}}","status":"{{alert.actionGroupName}}","value":"{{context.value}}","conditions":"{{context.conditions}}"}
    The action guide-webhook of the Actions step: Run when set to Query matched (callout 22), the action frequency For each alert with On status changes (callout 23), and the body, a JSON text with the rule name, the alert id, the action group name, the value and the conditions as action variables in double braces (callout 24)
  6. Click Add action again.

  7. Click the connector guide-webhook again.

  8. In Run when of the new action, select Recovered.

  9. In its body, type the message of the recovery:

    {"rule":"{{rule.name}}","status":"Recovered"}
    The Actions step with the first action collapsed and a second action guide-webhook below it: the Add action button is marked by callout 25, the connector title of the second action by callout 26, Run when set to Recovered by callout 27 and its body, a JSON text with the rule name and the status Recovered, by callout 28

Name the rule and create it

  1. In step 3 Details, type Guide Bookshelf error logs in Rule name.

  2. Click Create rule. Kibana creates the rule, which is enabled and runs within a minute.

    Step 3 Details of the rule page with the rule name Guide Bookshelf error logs marked by callout 29, the optional tags and investigation guide, and the buttons Cancel, Show request and Create rule at the bottom, with Create rule marked by callout 30

Force the failure and read the alert

  1. In a terminal, switch the load generator to its failing mode, which fills the log data stream with error records:

    curl -X POST localhost:8090/mode/failing
  2. After about a minute, open the primary navigation and, under Observability, click Alerts.

  3. In the table, find the row of the rule Guide Bookshelf error logs. Its status is Active.

  4. Click Alert details, the expand icon at the left of the row.

    Alerts page of Observability with the alert of the rule Guide Bookshelf error logs in the table: the status pill Active is marked by callout 33 and the Alert details icon of the row by callout 34, with the observed value 234 and the threshold > 5
  5. In the flyout, read the Reason: it names the document count of the last minute and the threshold.

    The Alert details flyout of the alert Guide Bookshelf error logs, titled Elasticsearch query breached, with the tabs Overview and Metadata; the Reason text, which says that the document count is 234 in the last 1m and that the alert fires when greater than 5, is marked by callout 35, above the Document Summary table
  6. In the terminal, read the last delivery of the webhook receiver. The receiver keeps the path and the body of every request it gets:

    curl -s localhost:8081 | jq '.[-1].body | fromjson'
    A terminal showing the command curl -s localhost:8081 piped to jq (callout 36) and the last delivery of the webhook receiver: a JSON object with the rule Guide Bookshelf error logs, the alert query matched, the status Query matched, the value 234 and the conditions Number of matching documents is greater than 5
  7. Return to normal traffic:

    curl -X POST localhost:8090/mode/normal
  8. Wait about two minutes, reload the alerts page and check that the status of the alert changed to Recovered.

  9. Read the deliveries of the receiver again. The last one is the recovery message of the second action:

    curl -s localhost:8081 | jq '.[-1].body | fromjson'

Check the result

The alert must go through the whole cycle. In the lab, with a rule that has these settings, the failing mode made the alert Active about 53 seconds after it was switched on, the webhook reached the receiver 3 seconds later with the document count in value, and the alert became Recovered about a minute and a half after normal traffic returned, with a second delivery that carries "status":"Recovered". Your timings differ by up to a check interval, because the rule runs once a minute and, after the return to normal mode, the window of one minute must first drain.

  • To see what the receiver holds, use curl -s localhost:8081 (the last 50 deliveries as JSON), or docker compose logs webhook-receiver from the lab folder, which prints one WEBHOOK line for each.

  • The path of every delivery of this guide is /guide-kibana.

  • To repeat the cycle, run curl -X POST localhost:8090/mode/failing again, wait for the alert and restore the traffic with curl -X POST localhost:8090/mode/normal.

  • The load generator mode is shown by curl localhost:8090/; leave it on normal when you finish.

Variations

  • ES|QL instead of KQL. In step 13 choose ES|QL as the query type and write a query that returns a row only when the errors exceed the threshold. The rule alerts when the query returns rows, filtered by the time field and the time window of the rule. The ES|QL form of this rule was not run in the lab:

    FROM logs-generic.otel-default
    | WHERE severity_text == "ERROR"
    | STATS errors = COUNT(*)
    | WHERE errors > 5
  • A shorter pass with Index threshold. Choose the card Index threshold in step 12, select the index logs-generic.otel-default and the time field @timestamp, and use the same sentence, WHEN count() OVER all documents IS ABOVE 5 FOR THE LAST 1 minute. This rule type aggregates the documents of the indices without a KQL query, so it counts all the log records, not only the errors, unless the form of your version offers a filter; use the Elasticsearch query rule when you need a query. The Index threshold form was not run in the lab.

  • The server log connector. Add a third action with the connector guide-server-log, Run when Query matched, and read the message in the log of the Kibana container with docker compose logs kibana from the lab folder. The server log connector was created in the lab but its output was not read.

  • Other frequencies. On status changes is the quiet choice; the other choices of Action frequency repeat the action or run it for a summary of the alerts, as the actions reference page explains.

What can go wrong

Symptom Cause Fix

The connector list has no Webhook, or the rule form has no Add action for it

The licence is not the trial of the lab.

Check that the lab started with the trial licence, as the hands-on lab page explains.

The alert becomes Active but nothing arrives at the receiver

The URL of the connector is wrong. From Kibana inside Docker the receiver is webhook.lab:8080 (or webhook-receiver:8080), not localhost:8081.

Edit the connector, correct the URL and use its Save & test button, then read curl -s localhost:8081.

The rule never fires

The data view is not Bookshelf logs (guides), the query has a typo, or the load generator is in normal mode.

Check the data view and the query with Test query, then run curl -X POST localhost:8090/mode/failing.

The alert stays Active long after normal traffic returned

The window of one minute still holds error records, or the next run has not happened yet.

Wait one or two check intervals; check the mode with curl localhost:8090/.

The body of the delivery contains the text of the variables, for example {{context.value}}

The variable was mistyped, or the body was sent as plain text without the double braces closed.

Retype the body exactly as in the listing and save the rule.

No recovery message arrives

The second action was not added or its Run when is not Recovered.

Edit the rule and check both actions.

Clean up

Keep the connectors and the rule while you do the following guides in this series: the next ones use alerts. To remove them, open Stack Management → Alerts and Insights → Rules and delete Guide Bookshelf error logs, then Connectors and delete guide-webhook and guide-server-log. Leave the load generator in the normal mode: curl -X POST localhost:8090/mode/normal.

Where to go next