Service Mesh (ASM) integrates with Simple Log Service (SLS), enabling Service Mesh (ASM) to collect access logs from your data plane clusters. This topic shows you how to enable log collection, configure SLS, and view the collected logs.
Background
Envoy proxies on the data plane (the Kubernetes clusters in your mesh) generate access logs for all traffic, known as Envoy access logs. While you can view these logs with the kubectl logs command, Simple Log Service (SLS) offers a more powerful solution for collecting, querying, and visualizing logs on dashboards.
Prerequisites
An ASM instance is created. For more information, see Create an ASM instance.
Step 1: Install the Logtail component
Existing cluster
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .
-
On the Add-ons page, search for logtail-ds and click Install on the logtail-ds card.
-
In the Install Comment logtail-ds dialog box, click Confirm.
The version of the logtail-ds add-on must be 0.16.24.0 or later. For more information about how to upgrade an add-on, see Manage components.
-
Add the cluster to the ASM instance. For more information, see Add a cluster to an ASM instance.
New cluster
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click Create Kubernetes Cluster.
-
In the Component Configurations step of the creation wizard, find the Log Service section and select Enable Log Service. This installs the logging add-on on the new Kubernetes cluster.
-
Select Project: Select an existing Project.
-
Create Project: Creates a new Project named
k8s-log-{ClusterID}to manage the collected logs.
-
-
After you complete the configurations, click Create Cluster.
-
Add the cluster to the ASM instance. For more information, see Add a cluster to an ASM instance.
Step 2: Configure log collection
To collect Envoy access logs with the Logtail component, create a collection configuration.
V1.17.2.35 and later
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the target instance. In the left-side navigation pane, choose .
-
On the Log Center page, go to the tab or the tab, enter a log retention period, and click Enable Sidecar Log Collection. In the Confirm dialog box, click OK.
Earlier than v1.17.2.35
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the Basic Information page, click Settings, select Collect access logs to Alibaba Cloud Log Service, and then click OK.
Step 3: View logs
Once configured, Envoy access logs are collected and stored in the SLS Project and Logstore that you specified. Follow these steps to view the logs.
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the Log Center page, on the Data-Plane Logs tab, on the Sidecar Proxy Logs tab, click Enable Sidecar Log Collection, and in the confirmation dialog box, click OK.
-
Detailed records: Navigate to to view raw access logs in a readable format.
The top of the page provides filters such as Namespace, pod, URL, Method, Status, and ResponseFlag. The table below displays fields for each access log, such as workload, date, time, direction, downstream, upstream, protocol, method, path, status code, response flag, latency, sent bytes, received bytes, and request ID.
-
Monitoring center: Navigate to to view multi-dimensional log statistics.
-