When a Classic Load Balancer (CLB) Layer 7 listener returns errors, access logs let you identify which backend server is causing the problem. CLB integrates with Simple Log Service (SLS) to store, query, and visualize these logs.
Only HTTP and HTTPS listeners support access logs. Layer 4 listeners do not.
Prerequisites
Before you begin, ensure that you have:
A CLB instance. See Create and manage CLB instances
A vServer group with backend servers added and applications deployed. See Create and manage a vServer group
An HTTP or HTTPS listener on the CLB instance. See Add an HTTP listener and Add an HTTPS listener
Simple Log Service activated. See Activate Simple Log Service
Step 1: Configure access logs
Log on to the CLB console.
Log on to the CLB console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region where your CLB instance is deployed.
If this is your first time using access logs, grant the required permissions. Click Authorize, then on the RAM Quick Authorization page click Agree to Authorization again.
NoteAuthorization is one-time only. If you use a Resource Access Management (RAM) user, the account owner must authorize the RAM user separately. See Authorize a RAM user to use the access log feature of CLB.
On the Access Log (Layer 7) page, find your CLB instance and click Configure in the Actions column.
In the Log Settings panel, set the Project and Logstore parameters, then click OK.
Parameter
Description
Project
An SLS project isolates and manages resources. Select an existing project from the drop-down list, or enter a name to create one. The project name must be unique, and its region must match the region of the CLB instance.
Logstore
An SLS Logstore collects, stores, and queries logs. Select an existing Logstore from the drop-down list, or enter a name to create one.
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 where your CLB instance is deployed.
Find your CLB instance and click View Logs in the Actions column to open the SLS console.
Log entries are generated each time a client accesses CLB. You can view the log data in Simple Log Service.
Enter an SQL statement to query log data. For example, you can run 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
Use the SLS dashboard to get a visual summary of backend server response times.
On the project page, hover over the
icon in the left-side navigation pane and click Dashboards.Click the access log dashboard name, for example slb_layer7_access_center_en.
In the top upstream_response_time section, sort the avg upstream_response_time(s) column in descending order.
If a backend server's average response time exceeds 1 second, log on to that server to investigate the root cause.