Log Service allows you to embed console pages in a user-created website. These pages include search and analysis pages and dashboard pages. This allows you to view log data with ease.

Background information

After you configure the required features of Log Service, you can search and analyze log data and access dashboard pages. These features include log collection, and search and analysis. You can also share log data with other users. This avoids high management costs due to the employment of multiple RAM users. Log Service allows you to embed specified search and analysis pages and dashboard pages in a user-created website. You can access these pages without the need to log on to the Log service console. You can use Resource Access Management (RAM) to control access to these pages, for example, grant the read-only permission to a RAM user. For more information, see Grant permissions to a RAM user.
Figure 1. Procedure
Procedure

Procedure

  1. Log on to a user-created website,and obtain a temporary AK pair and security token through the Web server access token service (STS).
    Note
  2. Call an STS SDK to obtain a token. This token allows you to log on to the Log Service console.
    Note
    • The STS token may contain several special characters. Before you use the token, use the URL encoding method to encode the special characters.
    • The STS token is valid for up to 3 hours. We recommend that you specify a URL for the user-created website. Each time you access this URL, you obtain a logon token. You are also redirected to Log Service pages based on the HTTP response status code 302.
    Sample request:
    http://signin-intl.aliyun.com/federation?Action=GetSigninToken
                        &AccessKeyId=<an AccessKey ID that is returned by STS>
                        &AccessKeySecret=<an AccessKey secret that is returned by STS>
                        &SecurityToken=<a token that is returned by STS>
                        &TicketType=mini
  3. Generate a logon-free URL.
    1. Obtain a URL to access Log Service resources.
      • Editable search and analysis page:
        https://sls4service.console.aliyun.com/next/project/<a project name>/logsearch/<a Logstore name>?hideTopbar=true&hideSidebar=true
      • Search and analysis page:
        https://sls4service.console.aliyun.com/next/project/<a project name>/logsearch/<a Logstore name>?isShare=true&hideTopbar=true&hideSidebar=true
      • Dashboard:
        https://sls4service.console.aliyun.com/next/project/<a project name>/dashboard/<a dashboard ID>?isShare=true&hideTopbar=true&hideSidebar=true
        Note The preceding dashboard ID appears only in the URL of a dashboard page. This ID does not match the name that appears on the dashboard.
    2. Generate a logon-free URL by using the logon token and the URL of Log Service page.
      Sample request:
      http://signin-intl.aliyun.com/federation?Action=Login
                                  &LoginUrl=<a URL that returns HTTP response status code 302 and directs you to a user-created website>
                                  &Destination=<the URL of a Log Service search and analysis page or dashboard page>
                                  &SigninToken=<a logon token>

Examples

The following sample scripts are written in Java, PHP, and Python:
  • Java
    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-sts</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-core</artifactId>
        <version>3.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.5</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.47</version>
    </dependency>
  • PHP
  • Python