Kibana Guide: Metric, Gauge and Table

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 three Lens panels to the dashboard Bookshelf (guides). A metric shows the number of log records, with the error ratio as a secondary metric, a badge and a trend behind the number. A gauge shows the error ratio between zero and ten percent, coloured green, yellow or red by ranges. A table lists the requests for each URI with the number of records, the errors and the error ratio, sorted, with coloured cells and a summary row.

Finished Kibana dashboard Bookshelf (guides) in view mode with a metric panel with a secondary metric, a trend badge and a trend in the background, a gauge with coloured ranges and a table of requests by URI with a summary row

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), ideally also the previous guide, Time series charts in Lens, which explains the formulas used here. The data view Bookshelf logs (guides) has the index pattern logs-generic.otel-default and the time field @timestamp.

  • The load generator must run in its default mode, which fills the log data stream. Lens and dashboards 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, and the numbers in the panels are only illustrations. A highlighted box with a number marks the control of the step with the same number. The chart type menu, the zones of the Metric, Gauge and Table layers and the dimension editors were not all opened one by one in the lab for this guide; the figures show them in general form and the steps name the controls without describing their exact layout.

Steps

The Lens editor is the one of the first guide: the field list at the left, the workspace in the middle and the configuration panel at the right. Its map is in Create a dashboard and the first Lens panel. For a Metric, a Gauge or a Table the layer has other zones than the axes, as the figures show.

Open Lens and choose Metric

  1. Open the primary navigation with the menu button, click Dashboards under Analytics, and click Bookshelf (guides).

  2. Click Edit in the second bar.

  3. Click Add in the second bar.

  4. In the Add to dashboard flyout, click Visualization.

    Bookshelf (guides) 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 of the flyout by callout 4
  5. Lens opens with an empty workspace. Click the chart type button of the layer, which shows Bar, and choose Metric.

    Empty Lens editor with the chart type button of the layer open as a menu listing Line, Metric and Gauge; the entry Metric is marked by callout 5

Build a metric with a secondary metric

  1. Drag the entry Records, above Available fields, onto the dashed Primary metric button. Lens shows the number of records of the time range as a big number.

    Lens editor with a Metric layer whose zones are Primary metric, Secondary metric, Maximum value and Break down by; the entry Records of the field list is dragged onto the dashed Primary metric button, marked by callout 6
  2. Click the dashed Secondary metric button, open the Formula tab of its editor and type the formula that divides the records with the severity ERROR by all the records:

    count(kql='severity_text : "ERROR"') / count()
  3. Type Error ratio in the name control of the editor, so that the panel shows that label instead of the formula.

  4. Set the Value format control to Percent, so that Lens shows 3.2% instead of 0.032.

  5. Turn on the trend badge of the secondary metric. The badge is a small coloured label that compares the secondary metric with another value.

    Dimension editor of the Secondary metric in Lens with the tab Formula selected: the formula of the error ratio is typed in the editor (callout 7), the Name control holds Error ratio (callout 8), the Value format control is set to Percent (callout 9) and the Trend badge switch is turned on (callout 10)
  6. Close the editor, click the Primary metric entry to open its editor, and set the Background chart to a trend. Lens draws the evolution of the number behind it, which needs the time field of the data view.

    Dimension editor of the Primary metric in Lens with the function Count on Records; the Background chart control set to Trend is marked by callout 11, and the metric card behind shows a faint trend under the number
  7. Close the editor and click Save and return in the second bar.

Build a gauge with ranges

  1. Back on the dashboard, click Add and then Visualization.

  2. Click the chart type button of the layer, which shows Bar, and choose Gauge.

    Empty Lens editor of a new visualization with the chart type menu open listing Metric, Gauge and Table; the entry Gauge is marked by callout 14
  3. Click the dashed Metric button, open the Formula tab and type the same formula as in the metric. Name it Error ratio and set its Value format to Percent, as in the steps 8 and 9.

  4. Click the dashed Maximum value button, open its Static value tab and type 0.1, so that the gauge goes from zero to ten percent.

    Lens editor with a Gauge layer: the dashed Metric button, where the formula of the error ratio goes, is marked by callout 15 and the dashed Maximum value button by callout 16; the workspace shows an empty gauge
  5. Click the Metric entry to open its editor.

  6. Set the colour to follow the value, and type the three ranges, each with its colour:

    From To Color

    0

    0.02

    green

    0.02

    0.05

    yellow

    0.05

    0.1

    red

    The needle stays in the green band up to two percent of errors, in the yellow band up to five percent and in the red band above.

    Dimension editor of the Metric of the gauge in Lens with the Color control set to By value and three ranges, from 0 to 0.02 in green, to 0.05 in yellow and to 0.1 in red; the list of ranges is marked by callout 18
  7. Close the editor and click Save and return.

Build a table with several metrics

  1. Click Add and then Visualization once more.

  2. Click the chart type button of the layer and choose Table.

    Empty Lens editor of a new visualization with the chart type menu open listing Gauge, Table and Bar; the entry Table is marked by callout 21
  3. Drag the field attributes.uri onto the dashed Rows button. Each URI becomes one row.

  4. Drag the entry Records onto the dashed Metrics button. The table gets a column Count of records.

    Lens editor with a Table layer whose zones are Rows and Metrics; the field attributes.uri of the list is dragged onto the dashed Rows button (callout 22) and the entry Records onto the dashed Metrics button (callout 23)
  5. Click the dashed button below Count of records, open the Formula tab and type the formula of the failed records:

    count(kql='severity_text : "ERROR"')
  6. Type Errors in the name control of the editor and close it.

  7. Click the dashed button below the new entry, open the Formula tab and type the formula of the ratio:

    count(kql='severity_text : "ERROR"') / count()
  8. Type Error ratio in the name control and set the Value format to Percent.

    Dimension editor of the third metric of the table in Lens with the tab Formula selected: the formula of the error ratio is typed in the editor (callout 26) and the Name control holds Error ratio (callout 27); the table behind has the columns attributes.uri, Count of records and Errors
  9. Close the editor. Click the header of the column Error ratio in the table preview and choose the option that sorts it in descending order, so that the URI with the most errors comes first.

    Lens editor with a Table layer of three metrics and the table preview with the columns attributes.uri, Count of records, Errors and Error ratio; the header of the column Error ratio is marked by callout 28
  10. Click the Error ratio entry and set Color by value to colour the cells, so that a high ratio stands out.

    Dimension editor of the Error ratio column of the table in Lens with the Color by value control set to Cell, marked by callout 29; the table behind has four columns
  11. Close the editor, click the Errors entry and set its Summary row to Sum. The table gets a last row with the total of the column.

    Dimension editor of the Errors column of the table in Lens with the Summary row control set to Sum and marked by callout 30; the table behind has four columns
  12. Close the editor and click Save and return.

  13. Back on the dashboard, click Save in the second bar.

  14. Click Exit edit.

Check the result

Open Dashboards and then Bookshelf (guides). It must show the metric with the error ratio below the number, the gauge and the table. In the normal mode the error ratio is close to 0%, so the needle of the gauge is in the green band.

To see the three panels react, force errors and press Refresh:

curl -X POST localhost:8090/mode/failing

Within about a minute the error ratio of the metric rises, the needle of the gauge moves into the yellow or the red band and the cells of the table change colour. Restore normal traffic afterwards:

curl -X POST localhost:8090/mode/normal

Variations

  • Break the metric down by attributes.uri with Break down by, to get one metric for each URI.

  • Add the field severity_text to the Rows of the table, as a second row field, to split each URI by severity.

  • Set a goal value in the gauge to mark the level you want to reach.

What can go wrong

Symptom Cause Fix

The metric shows no trend in the background

The background chart needs the time field of the data view, or the time picker covers too few points.

Use a data view with the time field @timestamp, and widen the time picker, for example to Last 1 hour.

The formula shows a red error

A function name or a quote is mistyped.

Retype the formula with the quotes as shown.

The gauge is empty or full

The maximum value does not match the metric: the metric is a ratio between 0 and 1, not a percentage between 0 and 100.

Set the maximum to 0.1, as in the guide, and keep the ranges in the same unit.

The table has a column with the formula as its title

The entry has no name.

Type the name in the editor of the entry.

The summary row is missing

The summary row is set per column, and the column has none.

Open the entry of the column and choose the function of the summary row.

Clean up

Keep the dashboard and the panels: the following guides in this series extend it. Stopping the profile with docker compose --profile kibana down -v deletes the volumes and therefore the dashboard.

Where to go next