On-demand Cross-Logstore Query and Analysis
The Multi-store Query and Analysis feature lets you temporarily query multiple LogStores in the same Project with a single statement to aggregate results. This streamlines troubleshooting and data analysis by eliminating the need to switch between query pages. Unlike a pre-configured, static StoreView, this feature provides a flexible, on-demand query capability, making it ideal for exploratory analysis and urgent troubleshooting scenarios.
Availability
This feature is currently in beta. To use it, submit a ticket. Supported regions:
|
Region name |
Region ID |
|
China (Hangzhou) |
cn-hangzhou |
|
China (Guangzhou) |
cn-guangzhou |
|
China (Beijing) |
cn-beijing |
|
China (Zhangjiakou) |
cn-zhangjiakou |
|
China (Heyuan) |
cn-heyuan |
|
China (Ulanqab) |
cn-wulanchabu |
|
China (Hohhot) |
cn-huhehaote |
|
China (Shenzhen) |
cn-shenzhen |
|
China (Chengdu) |
cn-chengdu |
|
China (Qingdao) |
cn-qingdao |
|
China (Fuzhou) |
cn-fuzhou |
|
China (Nantong) |
cn-nantong |
|
China (Hong Kong) |
cn-hongkong |
|
Japan (Tokyo) |
ap-northeast-1 |
|
Singapore |
ap-southeast-1 |
|
Malaysia (Kuala Lumpur) |
ap-southeast-3 |
|
Indonesia (Jakarta) |
ap-southeast-5 |
|
Philippines (Manila) |
ap-southeast-6 |
|
Thailand (Bangkok) |
ap-southeast-7 |
|
South Korea (Seoul) |
ap-northeast-2 |
|
Germany (Frankfurt) |
eu-central-1 |
|
UK (London) |
eu-west-1 |
Procedure
Step 1: Grant query permissions
Ensure that the RAM user or RAM role running the query has read permissions for all LogStores you intend to query. The query fails if read permissions are missing for even one LogStore.
To learn how to grant permissions to a RAM user or RAM role, see Create and authorize a RAM user or Create a RAM role for a trusted Alibaba Cloud service and grant permissions. You can grant permissions in one of the following ways:
-
(Recommended) Grant a custom policy: Create a custom policy that grants read permissions for only the target LogStores. The following sample provides the core permissions required. Replace
${projectName}and${logstoreName}with your Project name and the names of the LogStores to query.{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "log:ListProject" ], "Resource": "acs:log:*:*:project/*" }, { "Effect": "Allow", "Action": "log:GetProject", "Resource": "acs:log:*:*:project/${projectName}" }, { "Effect": "Allow", "Action": "log:ListLogStores", "Resource": "acs:log:*:*:project/${projectName}/logstore/*" }, { "Effect": "Allow", "Action": [ "log:GetLogStore", "log:GetLogStoreHistogram", "log:GetIndex", "log:GetLogStoreLogs" ], "Resource": [ "acs:log:*:*:project/${projectName}/logstore/${logstoreName}", "acs:log:*:*:project/${projectName}/logstore/${logstoreName}" ] } ] } -
Grant a system policy: Grant the
AliyunLogReadOnlyAccesssystem policy. This method is simpler but grants broad read-only permissions to all resources in Log Service.
Step 2: Go to the query page
In the Log Service console, go to the Multi-store Query and Analysis page.
-
Log on to the Log Service console.
-
In the Projects, click the target Project Name.
-
In the left-side navigation pane, choose Log Storage (
). In the Logstore list, click any LogStore to go to the Query Page. -
On the Query Page, click Multi-store Query and Analysis.

Step 3: Select the LogStores to query
Select the LogStores to query.
-
Click Add.
-
In the Add Store dialog box, move the LogStores to query (up to 50) from the Source LogStore list to the Applied LogStore list.
-
Click Confirm Add.
Step 4: Run the query
Write a query and analysis statement to run against the selected LogStores. In the search box on the Search / Analysis tab, enter the statement and click Search / Analysis.
Example
Suppose you have access logs for two applications stored in two LogStores named access-log-app1 and access-log-app2. To calculate the total page views for both applications, use the Multi-store Query and Analysis feature and run the following query and analysis statement:
* | SELECT __logstore__, count(*) AS pv GROUP BY __logstore__
Expected result:
The results are displayed in a table with two rows, listing the page views (pv) for access-log-app1 and access-log-app2 respectively. The __logstore__ is a built-in metadata field that identifies the source LogStore for each log entry.
|
LogStore |
pv |
|
access-log-app1 |
10520 |
|
access-log-app2 |
8790 |
Step 5 (Optional): Save As Data View
If you frequently query the same combination of LogStores, save it as a StoreView for reuse.
-
Add Data View permissions to the policy configured in Step 1: Grant query permissions. The required statement is as follows:
{ "Effect": "Allow", "Action": [ "log:ListStoreViews", "log:CreateStoreView", "log:GetStoreViewIndex", "log:GetStoreView" ], "Resource": "acs:log:*:*:/project/${projectName}/storeview/*" } -
Click Save As Data View.
-
In the dialog box that appears, enter a StoreView Name.
-
Click OK.
Quotas and limits
-
Project scope: You can query only LogStores in the same Project.
-
Number of LogStores: A single query can include a maximum of 50 LogStores.
-
Permission requirements: The RAM user or RAM role running the query must have the
log:GetLogStoreLogspermission for all selected LogStores. The query fails if permissions are insufficient for any selected LogStore. -
Index requirements: You must enable indexes for all selected LogStores. If a queried field does not have a field index in one of the LogStores, the query fails with an
index not configured for fielderror.
Billing
The Cross-Logstore Query and Analysis feature incurs no additional charges.
FAQ
Q: What should I do if the query returns the error Query failed, index not configured for field: [xxx]?
A: This error indicates that the field xxx in your query and analysis statement lacks a configured field index in one or more of the selected LogStores. Based on the error message, check the relevant LogStores and enable the field index and statistics for that field.
Q: Why did my query fail with a permission error?
A: Cross-Logstore Query and Analysis requires you to have read permissions for all selected LogStores. Follow the instructions in "Step 1: Grant query permissions" to ensure your RAM user or RAM role has the necessary permissions.
Troubleshooting tip: Try running the query with fewer LogStores, removing them one by one, to identify which LogStore has the permission issue.
Q: How can I run a single query across LogStores in different Projects?
A: The Cross-Logstore Query and Analysis feature only supports LogStores within the same Project. To query LogStores in different Projects, use Cross-Region Query and Analysis.