Alibaba Cloud API Gateway provides API hosting service to facilitate micro-service aggregation, frontend and backend isolation, and system integration. Each API request corresponds to an access record, which contains information such as the IP address of the API caller, requested URL, response latency, returned status code, and number of bytes for each request and response. With the preceding information, you can understand the operating status of your web services.

Figure 1. API Gateway
API Gateway

Log Service allows you to collect API Gateway access logs by using the data import wizard.

Characteristics

  1. Online log querying: You can use any keywords to query logs. Both exact query and fuzzy matching are supported. Log query can be used for troubleshooting or statistical query.
  2. Detailed API call logs: You can search for detailed API call logs.
  3. Customized analysis charts: You can customize charts based on any log data to meet your statistical and business requirements.
  4. Preset analysis reports: API Gateway has predefined global statistical charts, including those for the number of requests, success rate, failure rate, latency, the number of applications that call APIs, failure statistics, top groups, top APIs, and top latency.

Field description

Log field Description
apiGroupUid The ID of the API group.
apiGroupName The name of the API group.
apiUid The ID of the API.
apiName The name of the API.
apiStageUid The ID of the API stage.
apiStageName The name of the API stage.
httpMethod The HTTP method of the request.
path The request path.
domain The domain name that sends the request.
statusCode The HTTP status code.
errorMessage The error message.
appId The ID of the application that sends the request.
appName The name of the application that sends the request.
clientIp The IP address of the client that sends the request.
exception The specific error message returned by the backend server.
providerAliUid The account ID of the API provider.
region The ID of the region, such as cn-hangzhou.
requestHandleTime The time when the request is sent. It must be in GMT.
requestId The request ID. It must be globally unique.
requestSize The size of the request message. Unit: bytes.
responseSize The size of the response message. Unit: bytes.
serviceLatency The backend latency. Unit: ms.

Procedure

  1. Create a project and a Logstore.

    For more information about the creation, see Create a project and Create a Logstore.

    Skip this step if a Logstore already exists.

  2. Expand the target Logstore and click the plus sign (+) icon next to Data Import.
    You can also click the Import Data button on the right of the page, and select a Logstore in the data import process.Data Import
  3. Select a data type.

    Click API Gateway on the Import Data page.

  4. Select a Logstore.

    The system skips this step if you enter the log collection configuration process by clicking the plus sign (+) icon next to Data Import under a Logstore on the Logstores page.

  5. Specify the data source.

    In the step of specifying the data source, check whether you have completed the following configurations:

    1. Activate API Gateway.

      API Gateway provides a complete suite of API hosting services, helping you share services and data with partners in the form of APIs. It also allows you to release your APIs in the API marketplace for more developers to purchase and use.

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

    2. Complete RAM authorization.

      Use RAM to authorize Log Service before you establish a dispatch rule. This allows Log Service to collect your API Gateway logs.

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

    3. Create a dispatch rule.

      If this is the first dispatch rule that you create, the system automatically imports API Gateway logs and creates a dispatch rule. If you have configured API Gateway log collection, a message indicating that the log dispatch rule already exists is displayed. You can delete the existing dispatch rule.

  6. Configure query and analysis.

    By default, Log Service creates indexes for you. To create or modify indexes, choose Index Attributes > Modify on the search and analysis page.

You have completed data import initialization. You can select the api-gateway-access-log Logstore to query and analyze logs, or go to the dashboard page to view reports.