If you use CLB Layer 7 listeners and want to troubleshoot errors for backend servers, you can analyze the access log data to locate errors. CLB is interfaced with Simple Log Service, which can record and store access logs of CLB to help you efficiently analyze log data and locate errors.
Limits
Only Layer 7 CLB listeners, including HTTP and HTTPS listeners, support access logs.
Prerequisites
A CLB instance is created. For more information, see Create and manage a CLB instance.
A vServer group is created. For more information, see Create and manage a vServer group. Backend servers are added to the vServer group, and applications are deployed on the backend servers.
An HTTP or HTTPS listener is created for the CLB instance. For more information, see Add an HTTP listener and Add an HTTPS listener.
Log Service is activated. For more information, see Activate Simple Log Service.
Step 1: Configure an access log
- Log on to the CLB console.
In the left-side navigation pane, choose
.In the top navigation bar, select the region in which the CLB instance is deployed.
The first time you use the access log feature, you must grant the required permissions to your account. Click Authorize Now. On the Cloud Resource Access Authorization page, click Confirm Authorization Policy.
NoteYou only need to perform the authorization once.
If you use a Resource Access Management (RAM) user, you must authorize the RAM user by using the Alibaba Cloud account to which the RAM user belongs. For more information, see Authorize a RAM user to use the access log feature.
On the Access Logs (Layer-7) page, find the CLB instance that you want to manage and click Configure Logging in the Actions column.
In the Configure Logging panel, configure the Project and Logstore parameters and click OK.
Parameter
Description
Project
Projects in Simple Log Service are used to isolate and manage different resources.
Select Project: Select an existing project from the drop-down list.
Create Project: Enter a project name in the field.
NoteMake sure that the name of the project is unique and the region of the project is the same as that of the CLB instance.
Logstore
Logstores in Simple Log Service are used to collect, store, and query logs.
Select Logstore: Select an existing Logstore from the drop-down list.
Create Logstore: Enter a Logstore name in the field.
Step 2: View access log data
Log on to the CLB console.
In the left-side navigation pane, choose
.In the top navigation bar, select the region in which the CLB instance is deployed.
Find the CLB instance that you want to manage and click View Logs in the Actions column to go to the Simple Log Service console.
Log entries are generated when clients access CLB. You can view the log data in Simple Log Service.
Enter an SQL statement to query log data.
For example, you can enter the following SQL statement to query the top 20 most active clients. You can analyze the request sources and make informed business decisions.
* | select http_user_agent, count(*) as pv group by http_user_agent order by pv desc limit 20
Step 3: Locate unhealthy backend servers
You can locate unhealthy backend servers by checking the dashboard in Simple Log Service.
On the project page, move your pointer over the icon in the left-side navigation pane and click Dashboards.
Click the name of the access log, such as slb_layer7_access_center_e, to view log data.
On the dashboard, find the Top Upstream Response Time section. In this section, you can view the response time of CLB. You can sort the average upstream response time (s) data in descending order to check whether the response time of the backend server exceeds 1 second.
If the response time of a backend server exceeds 1 second, you can log on to the backend server to troubleshoot errors.
References
For more information about Simple Log Service, see What is Simple Log Service?.
For more information about CLB access logs, see Overview of CLB access logs and Configure a CLB access log.
For more information about the frequently asked questions (FAQ) about CLB and the solutions, see FAQ about CLB.