Alibaba Cloud API Gateway provides API hosting service to facilitate micro-service aggregation, frontend/backend isolation, and system integration. An access log is a log generated by Web services. Each API request corresponds to an access record, containing caller IP, requested URL, response latency, returned status code, number of bytes for each request and response, and other information. With the preceding information, you can understand the operation status of your Web services.

Figure 1. API gateway


With Log Service, you can collect access logs of the API Gateway by using Data Import Wizard.

Data migration

  1. Online log query:  You can perform a rapid accurate or fuzzy search using any keyword in the log. This feature can be used to locate a problem or count queries.
  2. Detailed call logs:  You can search for details of API call logs.
  3. Customized analysis chart: You can customize any log item into a statistical chart according to the statistical requirement to meet your business needs.
  4. Preset analysis report:  In the API Gateway, some global statistical charts are predefined, including request volume, success rate, failure rate, latency, the number of applications that call APIs, failure statistics, Top grouping, Top API, and Top latency.

Field Description

Log Fields Description
apiGroupUid The API group ID.
apiGroupName API group name
apiUid The API ID. 
apiName  The API name.
apiStageUid The API stage ID.
apiStageName The API stage name.
httpMethod The called HTTP method.
path The requested path.
domain The called domain name. 
statusCode  The HTTP status code.
ErrorMessage  Error message
appId  The application ID of the caller.
appName  The application name of the caller.
clientIp The client IP of the caller.
Exception The specific error message returned by backend.
providerAliUid The account ID of the API provider.
region such as cn-hangzhou
requestHandleTime The request time (GMT).
RequestId The request ID, which is globally unique.
requestSize The size of the returned data (in bytes).
Responsesize The size of the returned data (in bytes).
Servicelatency The backend latency (in milliseconds).

Procedure

  1. Create a project and a Logstore.

    For how to create a project and a Logstore, see Preparation

    Skip this step if a Logstore already exists.

  2. Enter the data access wizard.

    After creating a Logstore, click the Data Import Wizard icon on theLogstore List page .

  3. Select a data source.

    Click API Gateway in Cloud Services, and then click Next to go to the Configure Data Source step.

  4. Configure the data source.

    In the Configure Data Source step, check whether you have completed the following configurations:

    1. Activate the API Gateway service.

      API Gateway provides a complete API hosting service,  helping you open capabilities, services,  and data to your partners in the form of API. 

      If you have not activated the API Gateway service, activate it as instructed on the relevant page.

    2. Complete Resource Access Management (RAM) authorization. 

      Authorize Log Service by using RAM before establishing a dispatch rule, so that Log Service can collect your API Gateway logs.

      Click Authorize in the upper-right corner for quick authorization.

    3. Establish a dispatch rule. 

      If you do this for the first time, the system automatically imports API Gateway logs and establishes a dispatch rule. If you have configured API Gateway log collection before, a message indicating the log dispatch rule already exists is displayed. You can select to delete the existing dispatch rule.

    Click Next to enter the Search, Analysis, and Visualization page.

  5. Configure Search, Analysis, and Visualization.

    Configure indexes as shown in the following figure.  The configuration of the indexes is related to your log search and analysis efficiency.You will also use this configuration in Dashboard, so proceed with caution when modifying this configuration.

    Figure 2. Configure Indexes


    Click Next to complete the configuration.  Log shipper can be configured separately when necessary.

You have finished the data import wizard initialization. You can select the configured Logstore api-gateway-access-log to query and analyze logs, or go to Dashboard to view reports.