This topic describes how to enable the Layer 4 monitoring feature for a Server Load Balancer (SLB) instance in the SLB console. After you enable the feature, Layer 4 monitoring metrics are sent to Simple Log Service. The monitoring metrics are accurate to seconds.
Prerequisites
An SLB instance is created. For more information, see Create a CLB instance.
A TCP or UDP listener is configured for the SLB instance. For more information, see Add a TCP listener and Add a UDP listener.
A Simple Log Service project and a Metricstore are created in the region where the SLB instance resides. For more information, see Create a project and Create a Metricstore.
ImportantThe name of a Metricstore in a project must be different from the name of an existing Logstore in the project.
Procedure
Before you can use a RAM user to enable the Layer 4 monitoring feature, you must grant the required permissions to the RAM user. For more information, see RAM user authorization.
Log on to the SLB console.
In the left-side navigation pane, choose .
On the Instances page, click the ID of the SLB instance.
Click the Fine-grained Monitoring tab.
Enable the Layer 4 monitoring feature in the current region.
If the feature is already enabled in the current region, skip this step.
Click Enable Fine-grained Monitoring.
In the Enable Fine-grained Monitoring for SLB dialog box, select the project and Metricstore that you created, select I understand the above information, and then click OK.
When you perform this operation, the system automatically creates a RAM role named AliyunServiceRoleForSlbLogDelivery. SLB can assume this role to deliver Layer 4 monitoring metrics to Simple Log Service.
WarningDo not revoke permissions from the AliyunServiceRoleForSlbLogDelivery role or delete the role. Otherwise, logs cannot be sent to Simple Log Service.
Enable the Layer 4 monitoring feature for the TCP or UDP listener.
Click Settings.
On the Settings tab, turn on Fine-grained Monitoring for the TCP or UDP listener.
What to do next
After Simple Log Service collects Layer 4 monitoring metrics for the specified SLB instance, you can query, analyze, download, ship, and transform the metrics in the Simple Log Service console. You can also configure alert rules for the metrics. For more information, see Common operations on logs of Alibaba Cloud services.