Analyze time series data

edit

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.

When you’re done, you’ll have a complete overview of the sample web logs data.

Final dashboard with ecommerce sample data

Before you begin, you should be familiar with the Kibana concepts.

Add the data and create the dashboard

edit

Add the sample ecommerce data, and create and set up the dashboard.

  1. Go to the Home page, then click Try 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 the visualization editor

edit

Open the visualization editor, then make sure the correct fields appear.

  1. On the dashboard, click Create visualization.
  2. Make sure the kibana_sample_data_ecommerce data view appears, then set the time filter to Last 30 days.

Create visualizations with custom time intervals

edit

When you create visualizations with time series data, you can use the default time interval, or increase and decrease the interval. For performance reasons, the visualization editor allows you to choose the minimum time interval, but not the exact time interval. The interval limit is controlled by the histogram:maxBars setting and time range.

To analyze the data with a custom time interval, create a bar chart that shows you how many orders were made at your store every hour:

  1. From the Available fields list, drag Records to the workspace.

    The visualization editor creates a bar chart.

  2. To zoom in on the data, click and drag your cursor across the bars.

    Cursor clicking and dragging across the bars to zoom in on the data
  3. 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.

      Normalize unit converts Average sales per 12 hours into Average sales per 12 hours (per hour) by dividing the number of hours.

  4. To hide the Horizontal axis label, open the Bottom Axis menu, then deselect Show.

To identify the 75th percentile of orders, add a reference line:

  1. In the layer pane, click Add layer > Reference lines.
  2. Click Static value.
  3. Click the Percentile function, then enter 75 in the Percentile field.
  4. Configure the display options.

    1. In the Display name field, enter 75th.
    2. Select Show display name.
    3. From the Icon dropdown, select Tag.
    4. In the Color field, enter #E7664C.
  5. Click Close.

    Orders per day
  6. Click Save and return.

Analyze multiple data series

edit

You can create visualizations with multiple data series within the same time interval, even when the series have similar configurations with minor differences.

To analyze multiple series, create a line chart that displays the price distribution of products sold over time:

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

Create the 95th price distribution 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 copy a function, you drag it to the Drop a field or click to add field within the same group. To create the 90th percentile, duplicate the 95th percentile:

  1. Drag the 95th field to Add or drag-and-drop a field for Vertical axis.

    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. To create the 50th and 10th percentiles, repeat the duplication steps.
  5. Open the Left Axis menu, then enter Percentiles for product prices in the Axis name field.

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

Analyze multiple visualization types

edit

With layers, you can analyze your data with multiple visualization types. When you create layered visualizations, match the data on the horizontal axis so that it uses the same scale.

To analyze multiple visualization types, create an area chart that displays the average order prices, then add a line chart layer that displays the number of customers.

  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 price, then click Close.
  4. Open the Visualization type dropdown, then select Area.

Add a layer to display the customer traffic:

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

    1. In the Display name field, enter Number of 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, open the Layer visualization type menu, then click Line.

    Layer visualization type menu
  6. To change the position of the legend, open the Legend menu, then select the Alignment arrow that points up.

    Layer visualization type menu
  7. Click Save and return.

Compare the change in percentage over time

edit

By default, the visualization editor displays time series data with stacked charts, which show how the different document sets change over time.

To view change over time as a percentage, create an Area percentage chart that displays three order categories over time:

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

For each order category, create a filter:

  1. In the layer pane, click Add or drag-and-drop a field for Break down by.
  2. Click the Filters function.
  3. Click All records, enter the following in the query bar, then press Return:

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

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

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

    Prices share by category
  8. Click Save and return.

View the cumulative number of products sold on weekends

edit

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 Visualization type dropdown, then select Area.

Configure the cumulative sum of 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 weekend orders, then click Close.

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

  1. In the layer pane, click Add or drag-and-drop a field for Break down by.
  2. Click the Filters function.
  3. Click All records, enter the following in the query bar, 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.

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

Compare time ranges

edit

With Time shift, you can compare the data from different time ranges. To make sure the data correctly displays, choose a multiple of the date histogram interval when you use multiple time shifts. For example, you are unable to use a 36h time shift for one series, and a 1d time shift for the second series if the interval is days.

To compare two time ranges, create a line chart that compares the sales in the current week with sales from the previous week:

  1. On the dashboard, click Create visualization.
  2. Open the Visualization type dropdown, then select Line.
  3. From the Available fields list, drag Records to the workspace.
  4. To duplicate Count of Records, drag Count of Records to Add or drag-and-drop a field for Vertical axis in the layer pane.

To create a week-over-week comparison, shift Count of Records [1] by one week:

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

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

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

Time shifts can be used on any metric. The special shift previous will show the time window preceding the currently selected one in the time picker in the top right, spanning the same duration. For example, if Last 7 days is selected in the time picker, previous will show data from 14 days ago to 7 days ago. This mode can’t be used together with date histograms.

Analyze the percent change between time ranges

edit

With Formula, you can analyze the percent change in your data from different time ranges.

To compare time range changes as a percent, create a bar chart that compares the sales in the current week with sales from the previous week:

  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.
  4. Click Formula, then enter count() / count(shift='1w') - 1.
  5. Open the Value format dropdown, select Percent, then enter 0 in the Decimals field.
  6. In the Display name field, enter Percent of change, then click Close.

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

Analyze the data in a table

edit

With tables, you can view and compare the field values, which is useful for displaying the locations of customer orders.

Create a date histogram table and group the customer count metric by category, such as the continent registered in user accounts:

  1. On the dashboard, click Create visualization.
  2. Open the Visualization type dropdown, then select Table.
  3. From the Available fields list, drag customer_id to the Metrics field in the layer pane.

    1. In the layer pane, click Unique count of customer_id.
    2. In the Display name field, enter Customers, then click Close.
  4. From the Available fields list, drag order_date to the Rows field in the layer pane.

    1. In the layer pane, click the order_date.
    2. Select Customize time interval.
    3. Change the Minimum interval to 1 days.
    4. In the Display name field, enter Sales, then click Close.

To split the metric, add columns for each continent using the Columns field:

  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 dashboard

edit

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.
Final dashboard with ecommerce sample data