All Products
Search
Document Center

Simple Log Service:Configure multiple query statements

Last Updated:Dec 09, 2024

A pie chart is used to show the percentage of each category of data. The arc length of each slice in a pie chart is proportionate to the quantity that is represented by each category. A pie chart is divided into multiple slices based on the percentages of categories. Each slice shows the percentage of a category of data. The sum of all percentages is equal to 100%. This topic describes how to configure multiple query statements and use a pie chart to display the results of multiple query statements.

Prerequisites

Configuration effect

image

  1. Query and analyze data: You can query and analyze the collected logs in the Simple Log Service console. For example, you can retrieve logs, aggregate logs, and collect statistics on logs.

  2. Configure a pie chart: You can add multiple query statements on the Search & Analysis tab, configure a pie chart, and add the pie chart to a 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.

  2. In the left-side navigation pane, click Log Storage. In the Logstores list, click the Logstore that you want to manage.

    image

  3. On the page that appears, enter the following query statement in the search box and click Search & Analyze to view the logs.

    * | SELECT request_method, COUNT(*) as c group by request_method

    image

Step 2: Configure a pie chart

1. Add a pie chart

In the left-side navigation pane, choose Dashboard > Dashboards. In the Dashboard list, click the dashboard that you want to manage. In the upper-right corner of the dashboard page, click Edit. In edit mode, choose Add > Add Chart.

image

2. Configure multiple query statements

Multi-statement query with merging data

  1. Configure parameters on the Search & Analysis tab: On the left side of the Edit Chart page, configure the query time range, Logstore, Query statement A, and Query statement B based on the following figure. The following sample code shows Query statement A and Query statement B:

    * | SELECT request_method, COUNT(*) as c group by request_method

    image

  2. Configure parameters on the Data Conversion tab: On the left side of the Edit Chart page, click the Data Conversion tab, click Add Conversion, select Group By from the drop-down list, and then click Add Field. In the request_method section, select Group By from the drop-down list. In the c section, select Calculate and Sum from the drop-down lists based on the following figure.

    image

  3. Configure parameters on the General Configurations tab: On the right side of the Edit Chart page, click the General Configurations tab, choose Chart Types > image, and then configure parameters in the Query and Analysis Configurations section based on the following figure.

    • General Configurations > Query and Analysis Configurations > Category: The data of the pie chart is classified based on the request_method field.

    • General Configurations > Query and Analysis Configurations > Value Column: The numeric values are displayed based on the c field.

    image

  4. View the configuration effects.

    image

Multi-statement query without merging data

  1. On the right side of the Edit Chart page, choose General Configurations > Chart Types > image based on the following figure. On the left side of the page that appears, configure the query time range, Logstore, and query statement for the chart. After you complete the configuration, click Apply in the upper part of the Edit Chart page to view the configuration effects of the pie chart.

    • General Configurations > Query and Analysis Configurations > Category: The data of the pie chart is classified based on the request_method field.

    • General Configurations > Query and Analysis Configurations > Value Column: The numeric values are displayed based on the c field.

    image

  2. View the configuration effects.

    image