Configure a statistical chart with multiple queries

更新时间:
复制 MD 格式

A statistical chart can display results from multiple query statements, combining several single-value visualizations into one chart with customizable settings for each field.

Prerequisites

Overview

image

  1. Query and analyze data : Calculate the number of unique visitors (UV) and page views (PV) for a webpage in the Log Service console.

  2. Configure a statistical chart with multiple queries : Add a statistical chart to display both UV and PV data, set the background color for UV to orange and PV to blue, and then add the chart to the target dashboard.

Step 1: Query and analyze data

  1. Log on to the Simple Log Service console. In the Projects section, click the project you want.

    image

  2. In the left-side navigation pane, click Log Storage. In the Logstores list, click the target Logstore.

  3. Enter the following query statements and click Search & Analyze to view the logs.

    • Calculate the UV value.

      status < 400 | SELECT approx_distinct(client_ip) AS UV
    • Calculate the PV value.

      status < 400 | SELECT count(*) AS PV

Step 2: Configure a statistical chart with multiple queries

1. Add a statistical chart

In the left-side navigation pane, choose Dashboard > Dashboards. From the Dashboard list, click the target dashboard. In the upper-right corner of the dashboard, click Edit. In edit mode, click Add > Add Chart.

2. Configure multiple queries

On the right side of the page, go to General Configurations > Chart Type and select the statistical chart image. Configure the time range, Logstore, and query statements, and then click Apply to preview the chart.

  • General Configurations > Search & Analysis Settings > A: Select the UV field from query A.

  • General Configurations > Search & Analysis Settings > B: Select the PV field from query B.

Set the time range to 15min (Last 15 Minutes) and select the website_log Logstore. For Query A, set the query statement to status < 400 | SELECT approx_distinct(client_ip) AS UV. For Query B, set the query statement to status < 400 | SELECT count(*) AS PV. After you click Apply, the statistical chart displays both UV and PV results.

3. Configure colors

On the right side of the page, on the Field Configuration tab, customize the colors for the statistical chart. For more information, see Statistical chart.

  • In the A section, configure the visualization settings for query A results. Set the color to orange.

  • In the B section, configure the visualization settings for query B results. Set the color to blue.

In the Standard Configurations section, set the color for each group from the Color Scheme drop-down list. Select Solid as the scheme type.

4. Save the chart and dashboard

  1. In the upper-right corner of the chart editing page, click OK.

  2. In the upper-right corner of the dashboard editing page, click Save.