This topic describes how to configure Server Load Balancer (SLB) access logging. If you use a RAM user, the user must be assigned the required RAM role before SLB can write logs to Log Service.
- A Layer 7 SLB instance is created.
- Log Service is activated.
- Log on to the Server Load Balancer console.
- In the left-side navigation pane, choose .Note After the access log is configured, it cannot be closed temporarily.
- Select the region where the instance is deployed.
- Click Authorize. In the dialog box that appears, click Confirm Authorization Policy to authorize SLB to write logs to Log Service. If you log on to the console as a RAM user, you must first use your Alibaba Cloud account to authorize the RAM user. For more information, see Authorize a RAM user to use access logs.Note If you have authorized SLB, skip this step.
- On the Access Logs page, find the instance for which you want to configure access logs and click Configuring Logging in the Actions column.
- In the Configure Logging panel, select a project and a Logstore.
Note Make sure that the name of the project is globally unique and the region of the project is the same as that of the SLB instance.
- Project: the resource management unit in Log Service. It is used to isolate and control resources.
- Logstore: a unit in Log Service. It is used to collect, store, and query log data.
After you configure SLB access logging, you can query and search for logs by using the fields listed in the following table.
Field Description body_bytes_sent The size of the HTTP message body that is sent to the client. Unit: bytes. client_ip The IP address of the client that sends the request. host The host header in the request. http_user_agent The received http_user_agent header in the request. request_length The length of the request message, which includes the startline, HTTP headers, and HTTP body. request_method The request method. request_time The time interval between the first request received by SLB and the response sent by SLB. request_uri The received request URI. slbid The ID of the SLB instance. status The status code of the response from SLB. upstream_addr The IP address and port number of the backend server. upstream_response_time The time between establishing a connection and receiving the last byte of the response body from the backend server. upstream_status The status code of the response obtained by SLB from the backend server.
- Click OK.