Analyze time series dataedit

In this tutorial, you’ll use the ecommerce sample data to analyze sales trends, but you can use any type of data to complete the tutorial. Before using this tutorial, review the Kibana concepts.

Final dashboard with ecommerce sample data

Add the data and create the dashboardedit

Add the sample ecommerce data that you’ll use to create the dashboard panels.

  1. Go to the Kibana Home page, then click Try our sample data.
  2. On the Sample eCommerce orders card, click Add data.

Create the dashboard where you’ll display the visualization panels.

  1. Open the main menu, then click Dashboard.
  2. On the Dashboards page, click Create dashboard.

Open and set up Lensedit

Open Lens, then make sure the correct fields appear.

  1. From the dashboard, click Create visualization.
  2. Make sure the kibana_sample_data_ecommerce index appears.

    If you are using your own data, select the index pattern that contains your data.

View a date histogram with a custom time intervaledit

It is common to use the automatic date histogram interval, but sometimes you want a larger or smaller interval. For performance reasonse, Lens lets you choose the minimum time interval, not the exact time interval. The performance limit is controlled by the histogram:maxBars setting and the time range.

If you are using your own data, use one of the following options to see hourly sales over the last 30 days:

  • View less than 30 days at a time, then use the time filter to select each day separately.
  • Increase histogram:maxBars to at least 720, which is the number of hours in 30 days. This affects all visualizations and can reduce performance.

If you are using the sample data, use Normalize unit, which converts Average sales per 12 hours into Average sales per 12 hours (per hour) by dividing the number of hours:

  1. Set the time filter to Last 30 days.
  2. From the Available fields list, drag Records to the workspace.
  3. To zoom in on the data you want to view, click and drag your cursor across the bars.

    Added records to the workspace
  4. In the layer pane, click Count of Records.

    1. In the Display name field, enter Number of orders.
    2. Click Add advanced options > Normalize by unit.
    3. From the Normalize by unit dropdown, select per hour, then click Close.
  5. To hide the Horizontal axis label, open the Bottom Axis menu, then deselect Show.

    You have a bar chart that shows you how many orders were made at your store every hour.

    Orders per day
  6. Click Save and return.

Monitor multiple seriesedit

It is often required to monitor multiple series within a time interval. These series can have similar configurations with minor differences. Lens copies a function when you drag it to the Drop a field or click to add field within the same group.

To quickly create many copies of a percentile metric that shows distribution of price over time:

  1. On the dashboard, click Create visualization.
  2. Open the Chart Type dropdown, then select Line.
  3. From the Available fields list, drag products.price to the workspace.

Create the 95th percentile.

  1. In the layer pane, click Median of products.price.
  2. Click the Percentile function.
  3. In the Display name field, enter 95th, then click Close.

To create the 90th percentile, duplicate the 95th percentile.

  1. Drag the 95th field to the Drop a field or click to add field in the Vertical axis group.

    Easily duplicate the items with drag and drop
  2. Click 95th [1], then enter 90 in the Percentile field.
  3. In the Display name field enter 90th, then click Close.
  4. Repeat the duplication steps to create the 50th and 10th percentiles.
  5. Open the Left Axis menu, then enter Percentiles for product prices in the Axis name field.

    You have a line chart that shows you the price distribution of products sold over time.

    Percentiles for product prices chart
  6. Click Save and return.

Add multiple chart types or index patternsedit

To overlay visualization types or index patterns, add layers. When you create layered charts, match the data on the horizontal axis so that it uses the same scale.

  1. On the dashboard, click Create visualization.
  2. From the Available fields list, drag products.price to the workspace.
  3. In the layer pane, click Median of products.price.

    1. Click the Average function.
    2. In the Display name field, enter Average of prices, then click Close.
  4. Open the Chart Type dropdown, then select Area.

Create a new layer to overlay with custom traffic.

  1. In the layer pane, click +.
  2. From the Available fields list, drag customer_id to the Vertical Axis field in the second layer.
  3. In the second layer, click Unique count of customer_id.

    1. In the Display name field, enter Unique customers.
    2. In the Series color field, enter #D36086.
    3. Click Right for the Axis side, then click Close.
  4. From the Available fields list, drag order_date to the Horizontal Axis field in the second layer.
  5. In the second layer pane, open the Chart type menu, then click the line chart.

    Change layer type
  6. Open the Legend menu, then select the arrow that points up.
  7. Click Save and return.

Compare the change in percentage over timeedit

By default, Lens shows date histograms using a stacked chart visualization, which helps understand how distinct sets of documents perform over time. Sometimes it is useful to understand how the distributions of these sets change over time. Combine filters and date histogram functions to see the change over time in specific sets of documents. To view this as a percentage, use a Stacked percentage bar or area chart.

  1. On the dashboard, click Create visualization.
  2. From the Available fields list, drag Records to the workspace.
  3. Open the Chart type dropdown, then select Area percentage.

For each category type, create a filter.

  1. In the layer pane, click the Drop a field or click to add field for Break down by.
  2. Click the Filters function.
  3. Click All records, enter the following, then press Return:

    • KQLcategory.keyword : *Clothing
    • LabelClothing
  4. Click Add a filter, enter the following, then press Return:

    • KQLcategory.keyword : *Shoes
    • LabelShoes
  5. Click Add a filter, enter the following, then press Return:

    • KQLcategory.keyword : *Accessories
    • LabelAccessories
  6. Click Close.
  7. Open the Legend menu, then select the arrow that points up.

    Prices share by category
  8. Click Save and return.

View the cumulative number of products sold on weekendsedit

To determine the number of orders made only on Saturday and Sunday, create an area chart, then add it to the dashboard.

  1. On the dashboard, click Create visualization.
  2. Open the Chart Type dropdown, then select Area.

Configure the cumulative sum of the store orders.

  1. From the Available fields list, drag Records to the workspace.
  2. In the layer pane, click Count of Records.
  3. Click the Cumulative sum function.
  4. In the Display name field, enter Cumulative orders during weekend days, then click Close.

Filter the results to display the data for only Saturday and Sunday.

  1. In the layer pane, click the Drop a field or click to add field for Break down by.
  2. Click the Filters function.
  3. Click All records, enter the following, then press Return:

    • KQLday_of_week : "Saturday" or day_of_week : "Sunday"
    • LabelSaturday and Sunday

      The KQL filter displays all documents where day_of_week matches Saturday or Sunday.

  4. Open the Legend menu, then click Hide.

    Line chart with cumulative sum of orders made on the weekend
  5. Click Save and return.

Compare time rangesedit

Lens allows you to compare the selected time range with historical data using the Time shift option.

If multiple time shifts are used in a single chart, a multiple of the date histogram interval should be chosen, or the data points might not line up and gaps can appear. For example, if a daily interval is used, shifting one series by 36h, and another by 1d is not recommended. You can reduce the interval to 12h, or create two separate charts.

To compare current sales numbers with sales from a week ago, follow these steps:

  1. On the dashboard, click Create visualization.
  2. Open the Chart Type dropdown, then select Line.
  3. From the Available fields list, drag Records to the workspace.
  4. In the layer pane, drag Count of Records to the Drop a field or click to add field in the Vertical axis group.

To create a week-over-week comparison, shift the second Count of Records by one week.

  1. In the layer pane, click Count of Records [1].
  2. Open the Add advanced options dropdown, then select Time shift.
  3. Click 1 week ago.

    To define custom time shifts, enter the time value, the time increment, then press Enter. For example, to use a one week time shift, enter 1w.

    Line chart with week-over-week sales comparison
  4. Click Save and return.

Compare time ranges as a percent changeedit

To view the percent change in sales between the current time and the previous week, create a Formula.

  1. On the dashboard, click Create visualization.
  2. From the Available fields list, drag Records to the workspace.
  3. In the layer pane, click Count of Records.

    1. Click Formula, then enter count() / count(shift='1w') - 1.
    2. Open the Value format dropdown, select Percent, then enter 0 in the D*ecimals field.
    3. In the Display name field, enter Percent change, then click Close.

      Bar chart with percent change in sales between the current time and the previous week
  4. Click Save and return.

Create a table of customers by category over timeedit

Tables are useful when you want to display the actual field values. You can build a date histogram table, and group the customer count metric by category, such as the continent registered in user accounts.

In Lens you can split the metric in a table leveraging the Columns field, where each data value from the aggregation is used as column of the table and the relative metric value is shown.

  1. On the dashboard, click Create visualization.
  2. Open the Chart Type dropdown, then click Table.
  3. From the Available fields list, drag customer_id to the Metrics field in the layer pane.
  4. In the layer pane, click Unique count of customer_id.
  5. In the Display name field, enter Customers, then click Close.
  6. From the Available fields list, drag order_date to the Rows field in the layer pane.
  7. In the layer pane, click the order_date.

    1. Select Customize time interval.
    2. Change the Minimum interval to 1 days.
    3. In the Display name field, enter Sale, then click Close.

Add columns for each continent.

  1. From the Available fields list, drag geoip.continent_name to the Columns field in the layer pane.

    Date histogram table with groups for the customer count metric
  2. Click Save and return.

Save the dashboardedit

Now that you have a complete overview of your ecommerce sales data, save the dashboard.

  1. In the toolbar, click Save.
  2. On the Save dashboard window, enter Ecommerce sales, then click Save.
  3. Select Store time with dashboard.
  4. Click Save.