Kibana Guide: ES|QL Panels and Variable Controls

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 add a panel to the dashboard Bookshelf (guides) that is drawn from an ES|QL query instead of a data view: the number of Bookshelf log records per time bucket, split by HTTP status. Then you put two variable controls on the dashboard: Severity, a static list, and URI, a list that a query fills, that allows several selections and that depends on Severity. A reader changes the controls and the query runs again with the values they chose.

Finished Kibana dashboard Bookshelf (guides) in view mode with the controls Severity and URI above a line chart of the requests per time bucket, split by status

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 Create a dashboard and the first Lens panel, which creates the dashboard Bookshelf (guides) and shows the map of a dashboard in edit mode. The guide on Lens proportion and distribution charts is the previous one in the series but is not required. This guide queries the data stream logs-generic.otel-default directly, so it needs no data view, but the Bookshelf log records must be flowing.

  • The load generator sends traffic to the Bookshelf service in its default mode, which fills the log data stream. ES|QL panels and variable controls need no licence beyond the basic one; the lab runs a trial licence anyway.

  • The guide was checked on Elasticsearch and Kibana 9.5.6. The figures are drawings of the Kibana 9.5 user interface, not screenshots, so small details can differ from your screen. The layout of the query editor, of the suggestions and of the variable control flyout is drawn from the Elastic documentation, so look for the control by its name when it is not where a figure shows it. A highlighted box with a number marks the control of the step with the same number.

Steps

The guide works on a dashboard in edit mode and in the editor of an ES|QL panel. The map of the dashboard is in the first dashboard guide; come back to it when a control is not where a figure shows it. Kibana fills the variables ?_tstart and ?_tend with the bounds of the time picker, so the panel follows the time range of the dashboard.

Open an ES|QL panel

  1. Open Dashboards in the primary navigation and click Bookshelf (guides).

  2. Click Edit in the second bar.

    Kibana dashboard Bookshelf (guides) in view mode with its bar chart panel; the Edit button of the second bar is marked by callout 2
  3. Click Add in the second bar. The Add to dashboard flyout opens.

  4. In the flyout, click Visualization (query) ("Build charts, metrics, and tables with ES|QL."). On an empty dashboard the same editor is the card Create visualization (query).

    Dashboard in edit mode with the Add to dashboard flyout open: the Add button of the second bar is marked by callout 3 and the entry Visualization (query), which builds charts with ES|QL, by callout 4

Write the query and choose the chart

  1. Click in the query editor and type the query. It counts the log records of the dashboard time range in buckets of the time axis:

    FROM logs-generic.otel-default
    | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend
    | STATS requests = COUNT(*) BY bucket = BUCKET(@timestamp, 50, ?_tstart, ?_tend)
    | SORT bucket
  2. Run the query with the run button of the editor. The panel draws a chart from the result: a time column and a number column become a line or bar chart over time.

    The ES|QL editor of the new panel with the query FROM logs-generic.otel-default, a WHERE on the dashboard time range, STATS requests = COUNT(*) by a BUCKET of @timestamp and SORT bucket (callout 5); the run button at the end of the editor is marked by callout 6
  3. Edit the query to split the count by status: replace the STATS line with these two lines.

    | STATS requests = COUNT(*)
        BY bucket = BUCKET(@timestamp, 50, ?_tstart, ?_tend), status = attributes.status
  4. Run the query again. The first grouping column goes to the horizontal axis and the second one becomes the breakdown, so the chart now has one series per status.

    The ES|QL editor with the STATS command split by bucket and status = attributes.status (callout 7) above the line chart of the first query; the run button is marked by callout 8
  5. Look at the Suggestions next to the chart: they are alternative charts for the same result. Choose the one that draws a line chart with the two series 200 and 404.

    The ES|QL editor with a line chart of two series, 200 and 404, and the Suggestions cards at the right; the card of the line chart is marked by callout 9

Add a static control

  1. In the WHERE command, add a line below the time filter. As soon as you type ?severity, the editor offers its autocomplete list:

        AND severity_text == ?severity
  2. In the autocomplete list, choose Create control. A flyout for the variable control opens.

    The ES|QL editor with the line AND severity_text == ?severity typed into the WHERE command (callout 10); the autocomplete list under it offers Create control, marked by callout 11
  3. In the flyout, choose the control type that lists static values.

  4. Enter the values INFO and ERROR.

  5. Check that the variable name is ?severity and keep the label Severity. The control keeps single selection.

  6. Confirm the flyout with its save button.

    The variable control flyout over the ES|QL editor: the control type Static values (callout 12), the values INFO and ERROR (callout 13), the variable name ?severity (callout 14) and the label Severity; the save button is marked by callout 15

Add a control fed by a query, with several selections

  1. Add one more line to the WHERE command. MV_INTERSECTS keeps a record when its value is any of the selected values, which is what a control with several selections needs:

        AND MV_INTERSECTS(attributes.uri, ?uri)
  2. In the autocomplete list, choose Create control again.

    The ES|QL editor with the line AND MV_INTERSECTS(attributes.uri, ?uri) typed into the WHERE command (callout 16); the autocomplete list offers Create control, marked by callout 17
  3. In the flyout, choose the control type that takes its values from a query.

  4. Type the query of the control. It lists the URIs of the time range, and because it uses ?severity it only offers the URIs of the severity that is selected: that is how controls are chained.

    FROM logs-generic.otel-default
    | WHERE @timestamp <= ?_tend
        AND @timestamp > ?_tstart
        AND severity_text == ?severity
    | STATS BY attributes.uri
  5. Check that the variable name is ?uri and set the label to URI.

  6. Turn on Allow multiple selections. Several values then can be chosen at the same time, which only a value variable with a single question mark allows.

  7. Confirm the flyout with its save button.

    The variable control flyout with the control type Values from a query (callout 18) and its query, which uses ?severity (callout 19), the variable name ?uri (callout 20), the switch Allow multiple selections turned on (callout 21) and the save button (callout 22)

Use the controls on the dashboard

  1. Click Apply and close at the bottom of the editor. The panel is on the dashboard, and the two controls appear on it.

    The ES|QL editor with the finished query that uses ?severity and ?uri above the line chart; the Apply and close button at the bottom is marked by callout 23
  2. Open the Severity control and select INFO. The query runs again with that value.

  3. Open the URI control, which now lists the URIs of INFO records, and select two of them, for example /api/search and /api/books.

    Kibana dashboard in edit mode with two controls above the line chart panel: Severity, marked by callout 24, and URI, marked by callout 25
  4. Click Save in the second bar.

  5. Click Exit edit to return to view mode.

    Kibana dashboard in edit mode with the controls Severity set to INFO and URI set to /api/search and /api/books; the Save button of the second bar is marked by callout 26 and the Exit edit button by callout 27

Check the result

Open Dashboards and then Bookshelf (guides). The panel must show a line per status, and the Severity and URI controls must be above it. Select Severity ERROR and check that the URI control now offers only the URIs that have error lines; if the lab has none yet, force them:

curl -X POST localhost:8090/mode/log-errors

After about a minute press Refresh and open the Severity control again. Restore normal traffic afterwards:

curl -X POST localhost:8090/mode/normal

To see the query that really ran, open the panel menu and choose Inspect: the request shows the values of the controls and of the time picker in place of the variables.

Variations

  • Use a control with the double question mark, such as ??group_by, to let the reader choose the field of the BY clause. A field name needs that syntax: a value variable cannot stand in for a field.

  • Add a static control ?interval and use it in BUCKET(@timestamp, ?interval) to let the reader change the bucket size.

  • Turn the query into a table by choosing the table suggestion, for example to rank the URIs by count.

What can go wrong

Symptom Cause Fix

The panel shows an error about an unknown variable

The query mentions a variable that no control provides, or the control was deleted.

Create the control again from the autocomplete list, or remove the variable from the query.

The chart does not follow the time picker

The query has no filter on ?_tstart and ?_tend, or hard-codes a time such as NOW() - 1 hour.

Compare @timestamp with ?_tstart and ?_tend, as in step 5.

Allow multiple selections is on, but the query shows an error

The filter compares the field with ==, which takes one value.

Use MV_INTERSECTS(attributes.uri, ?uri) as in step 16.

The URI control is empty

No record of the selected severity exists in the time range.

Widen the time picker, or force records with curl -X POST localhost:8090/mode/log-errors and press Refresh.

A ?? variable does not accept several values

Only a value variable with one question mark allows multiple selection.

Keep one value, or use a value variable.

Clean up

Keep the dashboard: the following guides extend it. To remove it with everything else the lab stores, stop the profile with docker compose --profile kibana down -v, which also deletes the volumes and therefore the dashboard.

Where to go next