The Microservices Engine (MSE) traffic protection feature ensures business stability from multiple traffic-related dimensions such as traffic throttling, circuit breaking, degradation, and system overload protection. The MSE traffic protection feature provides more professional and stable traffic protection methods and traffic distribution analysis in seconds. If you want to query metrics in a more flexible manner during a long period of time, you can use the method of reporting traffic protection metrics to Simple Log Service. This topic describes how to report metric logs of the traffic protection feature of MSE Microservices Governance to Simple Log Service.
Prerequisites
Simple Log Service is activated. For more information, see "Step 1: Activate Simple Log Service" in Getting Started.
A Container Service for Kubernetes (ACK) cluster is created. For more information, see Create an ACK managed cluster or Create an ACK dedicated cluster.
The traffic protection feature is enabled for MSE Microservices Governance, and traffic protection rules are configured. For more information, see Overview.
Install Logtail
This section describes how to install the Logtail component. If Simple Log Service is enabled when you create the ACK cluster, skip this section. For more information, see Install Logtail when you create a cluster.
If you use an ACK dedicated cluster or an ACK managed cluster, you can follow the instructions in this section to install Logtail in your ACK cluster.
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, find the cluster that you want to manage and click its name. In the left-side navigation pane, choose .
On the Logs and Monitoring tab, find the logtail-ds resource card and click Install.
Collect data
This section describes how to configure the data source of Simple Log Service. Sentinel logs are collected, parsed, and reported to Simple Log Service. For more information, see the Configure data source and parsing format step in this topic.
Log on to the Simple Log Service console.
On the page that appears, click the Quick Data Import card. In the Import Data dialog box, enter Kubernetes in the search box, and click the Kubernetes - File card.
In the Select Logstore step, configure the Project and Logstore parameters, and click Next.
You can create a project whose name is in the k8s-log-{your ACK cluster ID} format or select a project from the Project drop-down list. You can select a Logstore from the Logstore drop-down list or create one. For more information about how to create a Logstore, see the Create a Logstore section in the "Manage a Logstore" topic.
In the Machine Group Configurations step, select the Kubernetes-group-${your ACK cluster ID} machine group, add the machine group in the Source Machine Group list to the Applied Server Groups list, and then click Next.
If you select another project, create a server group as prompted.
In the Logtail Configuration step, configure the data source and parsing format. Click Next.
Parameter
Description
Configuration Name
Enter a configuration name.
File Path
Enter a file path in the
${user_home}/logs/csp/{app_name}-metrics.log.{date}
format. Replace${user_home}
with the system home directory.NoteFor example, if the system home directory is root, the configuration file directory is
/root/logs/csp
and the file name is*metrics.log*
.For more information about the file path, see Important logs.
Log Sample
1724811932000|2024-08-28 02:25:32|com.alibabacloud.mse.demo.c.service.HelloServiceCTwo|24|0|24|0|1|0|1|202|OUT
Processing Method
Select Processors. The following figure shows the configurations for adding a processor of the Data Parsing (Delimiter Mode) type.
In the Query and Analysis Configurations step, wait until the Preview Data section on the right side of the page is automatically refreshed. Add and modify specific index fields, and click Next.
Verify log reporting
Log on to the Simple Log Service console.
In the Projects section, click the project that you select and select the Logstore that you configure. On the page that appears, check that the metric data is reported to the Logstore of Simple Log Service.
Create charts
After the metric data is reported to Simple Log Service, you can create related charts by using query and analysis statements of Simple Log Service based on your business requirements.