Loading

Build line charts with Kibana

Line charts are ideal for visualizing how metrics evolve over time, spotting seasonal patterns, and detecting spikes or regressions at a glance. Use them for KPIs like response time, error rate, throughput, or utilization, and compare multiple series or previous periods on the same chart. You can create line charts from any numeric data using aggregations (for example, Average, Percentile, Counter rate) or with custom formulas.

You can build a line chart in Kibana in either of these ways:

To automate chart or dashboard creation, use the Dashboards and Visualizations APIs. To create dashboards from natural-language instructions, use Elastic Agent Builder or the Kibana dashboards agent skill.

Example Lens line chart

Before you start, make sure you have data indexed into Elasticsearch or install sample data. The point-and-click editor uses data views to access your Elasticsearch data. Data views are usually created automatically when you ingest data. You can also create one manually to select the data that you want.

To build a line chart:

  1. Access Lens

    Lens is Kibana's main visualization editor. You can access it:

    • From a dashboard: On the Dashboards page, open or create the dashboard where you want to add the visualization, then add a new visualization.
    • From the Visualize library page by creating a new visualization.
  2. Set the visualization to Line

    Make sure that the visualization type is set to Line.

    When you drag a date or time field (such as @timestamp) onto an empty workspace, Line is automatically selected.

  3. Define the data to show

    1. Select the data view that contains your data.
    2. Drag a time field to the Horizontal axis and a numeric field to the Vertical axis. Kibana automatically selects an appropriate aggregation function compatible with the selected field.

    Optionally:

    • Add more numeric fields to create additional series, or drag a categorical field to Break down by to split the series.
    • You can click the Add layer icon to integrate additional visualizations, annotations, or a reference line.

    The chart preview updates to show one or more lines plotted over time. Each line represents a series, and data points are connected to show trends.

  4. Save the chart

    • If you accessed Lens from a dashboard, select Save and return to save the visualization and add it to that dashboard, or select Save to library to add the visualization to the Visualize library and be able to add it to other dashboards later.
    • If you accessed Lens from the Visualize library, select Save. A menu opens and lets you add the visualization to a dashboard and to the Visualize library.

Before you start, make sure you have data indexed into Elasticsearch or install sample data. ES|QL queries the indices named in the query directly, so you do not need a data view. The columns returned by the query become available as chart dimensions. Refer to Visualizations using ES|QL queries to learn how to open the editor, shape the query result for a visualization, and save the visualization.

A time-series line chart needs a time-bucket column for its horizontal axis and a numeric metric column to plot for each bucket. In this query, WHERE applies the dashboard time range, BUCKET divides that range into 50 adaptive groups, and COUNT returns one metric value for each group:

FROM kibana_sample_data_logs
| WHERE @timestamp <= ?_tend AND @timestamp > ?_tstart
| STATS requests = COUNT(*) BY time_bucket = BUCKET(@timestamp, 50, ?_tstart, ?_tend)
		

To build the chart:

  1. Create an ES|QL visualization and run the query.
  2. Set the visualization type to Line.
  3. Assign time_bucket to the Horizontal axis and requests to the Vertical axis.
  4. Customize the chart appearance using the line chart settings.
  5. Select Apply and close.

The chart preview shows how the request count changes over time.

After building the chart with the point-and-click editor or an ES|QL query, customize its appearance for your data and audience:

Use color wisely

Assign colors that match your users' expectations and consider your specific context.

Lens automatically applies the Elastic (line optimized) palette to line charts, which reorders colors for better contrast between adjacent series. You can override this by manually selecting a different palette.

Provide context
Add a legend and descriptive axis titles, or remove them for obvious axes.

Refer to Line chart settings for all line chart configuration options. For panel sizing and layout guidance, refer to Organize dashboard panels.

In line charts, you can enable time shift to compare the current value with a prior time range and identify deltas.

Example Lens line chart current previous

  1. Create a line chart with a time-based Horizontal axis and your main metric on Vertical axis, for example: bytes.
  2. Duplicate the layer:
    • Select Duplicate layer from the visualization editor.
    • Open the contextual menu of the visualization editor and select Duplicate layer.
  3. From the duplicated layer settings, select the field defined as vertical axis to open its details. Expand its Advanced options and set Time shift to 1w or to the time value of your choice. Check Compare differences over time for more details.
  4. Optionally, customize the appearance of the layer to adjust how it looks on the chart. When you duplicate a layer, Kibana automatically assigns a different Series color to the new layer. You can for example change this color, or adjust the layer's name and axis position. This name is used for the chart's legend.
Tip

You can also compute the relative change by defining the axis data with a formula, for example: (average(bytes) - average(bytes, shift='1w')) / average(bytes, shift='1w')

Use reference lines to indicate important thresholds, such as SLOs or alert limits.

Example Lens line chart reference lines

  1. In the chart settings, add a static value reference line to mark your target or threshold visually.
  2. Use the Text decoration setting to provide a name, for example, Target or SLO, choose a color, and optionally a band.

Customize your line chart to display exactly the information you need, formatted the way you want.

Data
  • Functions:
    • Top values: Show the most common values of a field.
      • Field: Select the field to group by. You can add up to 4 fields to create multi-term groups. When multiple fields are selected, each group represents a unique combination of values across those fields. You can reorder the fields by dragging them to change their priority.
      • Number of values: How many top values to display. The default number of values depends on your environment:
        • Defaults to 9.
        • Defaults to 5 for the first Top values dimension added to the chart and 3 for each additional one.
    • Rank by: Specifies the dimension the top values are ranked by. Available options:
      • Count of records: Rank by the number of documents containing each value. This is the default when a metric is defined.
      • Alphabetical: Rank by the term key alphabetically. This is the default when no metric is defined.
      • Rarity: Find terms that appear in very few documents, using a rare terms aggregation. You can configure the Max doc count per term to set the maximum number of documents a term can appear in to be considered rare (default: 1, max: 100). Available for single-field terms only, and not for floating-point numeric fields (float, double, half_float, and scaled_float).
      • Significance: Find statistically unusual terms compared to the overall data set, using a significant terms aggregation. Only available for keyword fields and single-field terms.
      • Custom: Define a custom metric aggregation to rank by (for example, rank by the sum of a numeric field rather than by count).
    • Rank direction: Ascending or descending order. Disabled when Rank by is set to Rarity or Significance.
    • Date histogram: Group data into time-based buckets.
      • Field: Select the date field to use for the time-based grouping.
    • Include empty rows: Include buckets that contain no matching documents. Existing saved visualizations keep their configured setting.

      • For new visualizations, this option is:

        • On by default for tables, line charts, and area charts
        • Off by default for bar charts, heat maps, pie charts, treemap charts, mosaic charts, waffle charts, metric charts, and tag clouds

        When you switch visualization or series type, Lens applies the default for the new type. If you switch back to the visualization type you saved, Lens restores the saved setting.

      • This option is on by default for all visualization types.

    • Bind to global time picker: Associate the selected field to the Lens or dashboard main time selector.

    • Minimum interval: Define the time interval for aggregating the data. For example, 30s, 20m, 24h, 2d, 1w, 1M

    • Drop partial intervals: Exclude incomplete intervals from the data. This option is off by default.

    • Intervals: Create numeric ranges for continuous data by grouping a numeric field into buckets.
      • Field: Select the numeric field to create intervals from.
      • Intervals granularity: Use the slider to control how many intervals to create. Kibana divides the field into evenly spaced intervals (incremented by 10, 5, or 2) between the field's minimum and maximum values. The minimum granularity is 1, and the maximum is set by the histogram:maxBars advanced setting.
      • Create custom ranges: Define your own ranges with specific lower and upper bounds and optional labels, instead of using the automatic granularity.
      • Include empty rows: Include intervals that contain no matching documents. Existing saved visualizations keep their configured setting.
        • For new visualizations, this option is:

          • On by default for tables, line charts, and area charts
          • Off by default for bar charts, heat maps, pie charts, treemap charts, mosaic charts, waffle charts, metric charts, and tag clouds

          When you switch visualization or series type, Lens applies the default for the new type. If you switch back to the visualization type you saved, Lens restores the saved setting.

        • This option is on by default for all visualization types.

    • Filters: Define custom KQL filters. Each filter creates one group from the documents that match its query.
Appearance
Name: By default, the chart uses the function or formula as title. It's a best practice to customize this with a meaningful title.
Data

To represent the metrics or values you want to visualize, you can use quick functions like Average, Count, Percentile, Counter rate, or create custom calculations with formulas. Refer to Lens visualizations > Use formulas to perform math for examples, or to the Formula reference available from Lens.

Appearance

  • Name: Customize the legend label with a descriptive name.
  • Value format: Control how numeric values are displayed on the vertical axis of your visualization.
  • Series color: Select a palette or specific color per series.
  • Axis side: Control where axis labels and tick marks appear.

Breakdown functions segment your data into multiple lines on the same chart, with each line representing a different value of a categorical field. You can specify the following options:

Data
  • Functions:
    • Top values: Show the most common values of a field.
      • Field: Select the field to group by. You can add up to 4 fields to create multi-term groups. When multiple fields are selected, each group represents a unique combination of values across those fields. You can reorder the fields by dragging them to change their priority.
      • Number of values: How many top values to display. The default number of values depends on your environment:
        • Defaults to 9.
        • Defaults to 5 for the first Top values dimension added to the chart and 3 for each additional one.
    • Rank by: Specifies the dimension the top values are ranked by. Available options:
      • Count of records: Rank by the number of documents containing each value. This is the default when a metric is defined.
      • Alphabetical: Rank by the term key alphabetically. This is the default when no metric is defined.
      • Rarity: Find terms that appear in very few documents, using a rare terms aggregation. You can configure the Max doc count per term to set the maximum number of documents a term can appear in to be considered rare (default: 1, max: 100). Available for single-field terms only, and not for floating-point numeric fields (float, double, half_float, and scaled_float).
      • Significance: Find statistically unusual terms compared to the overall data set, using a significant terms aggregation. Only available for keyword fields and single-field terms.
      • Custom: Define a custom metric aggregation to rank by (for example, rank by the sum of a numeric field rather than by count).
    • Rank direction: Ascending or descending order. Disabled when Rank by is set to Rarity or Significance.
    • Date histogram: Group data into time-based buckets.
      • Field: Select the date field to use for the time-based grouping.
    • Include empty rows: Include buckets that contain no matching documents. Existing saved visualizations keep their configured setting.

      • For new visualizations, this option is:

        • On by default for tables, line charts, and area charts
        • Off by default for bar charts, heat maps, pie charts, treemap charts, mosaic charts, waffle charts, metric charts, and tag clouds

        When you switch visualization or series type, Lens applies the default for the new type. If you switch back to the visualization type you saved, Lens restores the saved setting.

      • This option is on by default for all visualization types.

    • Bind to global time picker: Associate the selected field to the Lens or dashboard main time selector.

    • Minimum interval: Define the time interval for aggregating the data. For example, 30s, 20m, 24h, 2d, 1w, 1M

    • Drop partial intervals: Exclude incomplete intervals from the data. This option is off by default.

    • Intervals: Create numeric ranges for continuous data by grouping a numeric field into buckets.
      • Field: Select the numeric field to create intervals from.
      • Intervals granularity: Use the slider to control how many intervals to create. Kibana divides the field into evenly spaced intervals (incremented by 10, 5, or 2) between the field's minimum and maximum values. The minimum granularity is 1, and the maximum is set by the histogram:maxBars advanced setting.
      • Create custom ranges: Define your own ranges with specific lower and upper bounds and optional labels, instead of using the automatic granularity.
      • Include empty rows: Include intervals that contain no matching documents. Existing saved visualizations keep their configured setting.
        • For new visualizations, this option is:

          • On by default for tables, line charts, and area charts
          • Off by default for bar charts, heat maps, pie charts, treemap charts, mosaic charts, waffle charts, metric charts, and tag clouds

          When you switch visualization or series type, Lens applies the default for the new type. If you switch back to the visualization type you saved, Lens restores the saved setting.

        • This option is on by default for all visualization types.

    • Filters: Define custom KQL filters. Each filter creates one group from the documents that match its query.
  • Collapse by: Aggregate all metric values that share the same value for this dimension into a single number, removing it as an independent grouping. Available aggregation methods: Sum, Min, Max, or Average.
Appearance

Allow you to customize how your breakdown data is displayed in line charts, including:

  • Name: It's a best practice to customize this with a meaningful title.
  • Value format: Control how numeric values are displayed in your visualization.
  • Color mapping: Determine how colors are assigned to your breakdown series.

When creating or editing a visualization, you can adjust the following settings.

Average RAM per host
Monitoring the average of RAM over time for the first four hosts:
  1. Drag @timestamp to the Horizontal axis and set the following settings:
    • Functions: Date histogram
    • Minimum interval: Hour
  2. Drag machine.ram to the Vertical axis and set the following settings:
    • Functions: : Moving average
    • Value format: Bytes
  3. In the Breakdwon panel, set the following settings:
    • Functions: Top values
    • Fields: host.keyword
    • Number of values: 4
  4. Save your chart.

Average RAM per host

Unique IPs over time
Visualize the number of unique client IPs throughout the day to identify traffic patterns and peak usage periods:
  1. Drag timestamp to the Horizontal axis and set Functions to Date histogram with Minimum interval set to Hour.
  2. Drag clientip to the Vertical axis and set the following settings:
    • Functions: Unique count
    • Value format: Number
    • Decimals: 0
  3. In the Visual options, set Missing values to Linear to connect gaps in the line.
  4. Save your chart.

Unique IPs throughout the day