All Products
Search
Document Center

Server Load Balancer:Use CLB access logs to locate unhealthy backend servers

Last Updated:Jan 19, 2024

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

Step 1: Configure an access log

  1. Log on to the CLB console.
  2. In the left-side navigation pane, choose Logs > Access Log.

  3. In the top navigation bar, select the region in which the CLB instance is deployed.

  4. 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.

    Note

    You 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.

  5. On the Access Logs (Layer-7) page, find the CLB instance that you want to manage and click Configure Logging in the Actions column.

  6. 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.

    Note

    Make 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

  1. Log on to the CLB console.

  2. In the left-side navigation pane, choose Logs > Access Log.

  3. In the top navigation bar, select the region in which the CLB instance is deployed.

  4. 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.

  5. Log entries are generated when clients access CLB. You can view the log data in Simple Log Service.

  6. 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.

  1. On the project page, move your pointer over the image.png icon in the left-side navigation pane and click Dashboards.

  2. Click the name of the access log, such as slb_layer7_access_center_e, to view log data.

  3. 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