All Products
Search
Document Center

:Use StoreView to query logs across Logstores

Last Updated:Aug 28, 2024

In actual business scenarios, logs are generated by different applications, services, or cloud services and stored in projects in different regions or in different Logstores in the same region. Simple Log Service provides the StoreView feature that allows you to perform JOIN queries on logs across regions and Logstores.

How it works

image
  • StoreViews and Logstores are resources in projects. Unlike Logstores, StoreViews are not entity resources that are used to store logs. Instead, StoreViews are virtual resources that are used to store associations among multiple Logstores. A StoreView can be associated with only Logstores. You can use StoreViews to query logs in different Logstores in a unified manner. However, you cannot use StoreViews to modify logs.

  • StoreViews allow you to perform JOIN queries on logs in different Logstores. For example, Logstore 1 and Logstore 2, which are associated with StoreView 1, include the age field. If you query the age field in StoreView 1, all logs that contain the age field in Logstore 1 and Logstore 2 are returned.

    创建索引的草稿 (2)

StoreView-related permissions

If you use the StoreView feature as a Resource Access Management (RAM) user or a RAM role, the RAM user or RAM role must have the required permissions. For information about how to use an Alibaba Cloud account to grant permissions to a RAM user or a RAM role, see Create a RAM user and authorize the RAM user to access Simple Log Service, Create a RAM role whose trusted entity is an Alibaba Cloud service and grant the RAM role the permissions to access Simple Log Service, and Create a RAM role whose trusted entity is an Alibaba Cloud account and grant the RAM role the permissions to access Simple Log Service.

You can attach system policies or custom policies to a RAM user.

  • System policy: All system policies are created and updated by Alibaba Cloud. You can use system policies but cannot modify the policies.

  • Custom policy: You can create, modify, delete, and update custom policies to meet your business requirements.

    • When you create a StoreView or query logs in a StoreView as a RAM user or a RAM role, the RAM user or RAM role must have the permissions to call the GetLogs operation in all associated Logstores. To grant the permissions, add the following content to the custom policy:

      {
         "Action": "log:GetLogs",
         "Resource":[
            "acs:log:*:*:project/${projectName}/logstore/*",
            "acs:log:*:*:project/${projectName}/StoreView/*"
          ]
         "Effect": "Allow"
       }

Limits

  • Up to 10 StoreViews can be created for each project.

  • Each StoreView can be associated with up to 50 Logstores.

  • All Logstores in a StoreView must belong to the same Alibaba Cloud account. Otherwise, an error is reported when you query logs in the StoreView.

Prerequisites

Logstores are created. For more information, see Create a Logstore.

Create a StoreView

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project that you want to manage.

    image

  3. On the left side of the console, choose Storeview > Storeview for Logstore, and then click the image icon to create a StoreView.

    image

  4. In the dialog box that appears, add the Logstores with which you want to associate.

    Important
    • Restrictions on the Storeview Name:

      • A Logstore name can contain only lowercase letters, digits, and underscores (_).

      • The name must start with a lowercase letter and end with a lowercase letter or a digit.

      • The name must be 3 to 63 characters in length.

    • Creating a StoreView requires approximately 1 minute to complete.

    • If cross-border JOIN queries are required, read and agree to Compliance Warranty on Cross-border Data Transfer and click OK.

    image

Query logs in a StoreView

  1. On the Storeview page, click the name of the StoreView that you want to manage to go to the log search page.

  2. Enter a query statement. A search statement is used to query and filter data. A search statement supports only simple queries. You can specify conditions in a search statement to filter data. The conditions include time ranges, request types, and keywords. You can separately use a search statement. For more information, see Search syntax.

  3. Specify the time range of data that you want to query or analyze. In the upper part of the query and analysis page, select a time range from the drop-down list. Example: Last 15 Minutes.

    Important

    By default, after a query statement is executed, only 100 rows of data are returned. To increase the number of rows of data that are returned, you can use a LIMIT clause. For more information, see LIMIT clause.

    For information about other features on the log search page, see Query and analyze logs.

    Important

    Features such as real-time consumption and data processing are not supported by StoreViews. The actual supported features on the Simple Log Service console shall prevail.

    For information about how to query logs in a StoreView that has multiple associated Logstores, see Search syntax. The reserved field __tag__ is used to display the project and Logstore in which logs are generated.