Configure a multi-statement query
A pie chart displays data as proportional slices of a whole. Each slice represents a category, and its size shows the percentage of the total. You can configure a multi-statement query to combine results from multiple query statements into a single pie chart.
Prerequisites
-
You have collected data. For more information, see Collect text logs from servers.
-
You have created an index. For more information, see Create indexes.
-
You have created a dashboard. For more information, see Create a dashboard.
Example

-
Search and analyze data: Query and analyze logs to retrieve and aggregate statistics.
-
Configure a pie chart: Add multiple query statements, configure a pie chart, and add it to a dashboard.
Step 1: Search and analyze data
Log on to the Simple Log Service console. In the Projects section, click the project you want.

-
In the navigation pane on the left, click Log Storage. In the Logstore list, click your Logstore.

-
Enter the following query statement and click Search & Analyze to view the logs.
* | SELECT request_method, COUNT(*) as c group by request_method
Step 2: Configure a pie chart
1. Add a pie chart
In the navigation pane on the left, choose . From the Dashboard list, click your dashboard. In the upper-right corner of the dashboard, click Edit. In edit mode, click .

2. Configure the multi-statement query
With data merging
-
Configure queries: On the left side of the Edit Chart page, configure the time range, Logstore, Query A, and Query B, as shown in the following figure. The following query statement is used for both Query A and Query B:
* | SELECT request_method, COUNT(*) as c group by request_method
-
Configure data conversion: On the Data Conversion tab on the left side of the Edit Chart page, click , and then click Add Field. Configure and .

-
General Configurations: On the right side of the Edit Chart page, select , and then configure the Query and Analysis settings.
-
: Categorizes the pie chart by the
request_methodfield. -
: Displays the value of each category using the
cfield.

-
-
View the chart.

Without data merging
-
On the right side of the page, select . On the left side, configure the query time range, Logstore, and query statement. Then, click Apply at the top of the page to preview the chart.
-
: Categorizes the pie chart by the
request_methodfield. -
: Displays the value of each category using the
cfield.

-
-
The following figure shows the resulting chart.






