The API Gateway and Log Service are seamlessly integrated. The Log Service enables you to view real-time log information, download logs, and analyze logs from multiple dimensions. You can also send logs to OSS or MaxCompute.
For details about more Log Service functions, see Log Service help.
You can use the Log Service free-of-charge for the first 500 MB of log data every month. For the prices of other items, see Log Service pricing.
You can specify any keyword in logs to complete an exact or fuzzy log search quickly. The search results can be used for fault location or log statistics collection.
You can obtain detailed API call information based on the following log items:
|apiGroupUid||API group ID|
|apiGroupName||API group name|
|apiStageUid||API environment ID|
|apiStageName||API environment name|
|httpMethod||Called HTTP method|
|domain||Called domain name|
|appId||Caller application ID|
|appName||Caller application name|
|clientIp||IP address of the caller client|
|exception||Specific error message returned from the backend|
|providerAliUid||API provider account ID|
|region||Region name, such as cn-hangzhou|
|requestHandleTime||Request time (UTC)|
|requestId||Request ID, globally unique|
|requestSize||Request size, unit: byte|
|responseSize||Returned data size, unit: byte|
|serviceLatency||Backend latency, unit: millisecond|
You can define statistical charts of any log items to obtain statistical data required for business operation.
The API Gateway provides predefined statistical charts (global) for you to use directly. These statistical charts show log items including the request size, success rate, error rate, latency, number of applications that call an API, error statistics, top groups, top APIs, and top latencies.
Before using this function, make sure that you have subscribed to the log service and created a project and a logstore. Click here to create a project and logstore.
You can configure the Log Service on the API Gateway console or Log Service console.
1) Open API Gateway Console and choose “Publish APIs” > “Log Manage” and select the region of your service. In the following figure, China East 1 is used as an example.
2) Click “Create Log Config” to display the log configuration page.
3) Select the project or logstore where the log service is required. If no options are available, click “Authorize Log Service Log Write Operation”, and then grant the authority to access your cloud resources.
4) After you confirm the authorization, the API Gateway is successfully associated with the log service.
5) Enable the indexing function to complete the configuration.
For details, see Access logs of API Gateway.
After the configuration is complete, your API calls can be recorded in the logstore for the log service.
You can also log on to the Log Service console to view logs. For details, see Query logs.
Predefined reports are statistical reports preset on the API Gateway to facilitate log statistics collection. Open API Gateway console and choose “Publish APIs” > “Log Manage” > “Access Log” to view the predefined reports. You can also view these predefined logs on the Log Service console.
You can define query reports to meet your own business requirements. For details, see Dashboard.
Open API Gateway Console and choose “Publish APIs” > “Log Manage” to modify or delete log configuration.
- Modify Config: Change the project or logstore for the log service. Then API call logs are written in the new logstore, but historical logs are still saved in the original logstore and not migrated to the new logstore.
- Delete Config: Delete the mapping between the API Gateway and log service. The API call logs are no longer synchronized to the log service, but the historical logs in the logstore are not deleted.