Service Mesh (ASM) provides observability configurations for logs, metrics, and tracing. You can use the ASM console to customize these configurations for the entire mesh, a specific namespace, or a specific workload. For example, you can set the log output format, define metric dimensions, enable or disable specific metrics, and set the sampling rate for tracing. This topic describes how to use the observability configuration feature.
Prerequisites
An ASM instance of version 1.17.2.35 or later is created. For more information, see Create an ASM instance or Upgrade an ASM instance.
Applicable scope
Type | Description |
Global | Global configurations support settings for logs, metrics, and tracing. Only one global configuration exists, and it cannot be deleted. Only global configurations support tracing settings. |
Namespace | Create a dedicated observability configuration for a namespace. Each namespace can have only one namespace-level observability configuration. |
Custom | Use a workload selector to define the scope of a custom configuration. Each workload can be selected by at most one custom configuration. |
Procedure
Global
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 Observability Settings page, click the Global tab, configure logs, metrics, and Tracing Analysis as needed, and then click Submit.
Click the links in the following table to view detailed descriptions of the configurations.
Configuration area
Description
Namespace
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 Observability Configuration page, click the Namespace tab, click Create, select the target Namespace, configure logs and metrics as needed, and then click Create.
Click the links in the following table to view detailed descriptions of the configurations.
Configuration area
Description
Custom
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 Observability Configuration page, click the Custom tab, select the target Namespace, click Create, enter a Name and Matching Labels, configure logs and metrics as needed, and then click Create.
Click the links in the following table to view detailed descriptions of the configurations.
Configuration area
Description
Log settings
Log settings include enabling or disabling access log output, setting the log output format, customizing the log format, and log filtering.
Enable or disable access log output
In the Log Settings area, turn on or off the Enable Log Output switch as needed.
If you turn on the switch, the Envoy proxy on the data plane of the service mesh outputs access logs to the standard output of the container.
If you turn off the switch, the Envoy proxy on the data plane of the service mesh stops outputting logs to the standard output of the container.
View Waypoint logs.
The following example shows how to view access logs using kubectl.
Run the following command to view Waypoint logs.
kubectl -n istio-egress logs deployments/waypoint | tail -1 | jqRun the following command to view ingress gateway logs.
kubectl -n istio-system logs istio-ingressgateway-6cff9b6b58-r**** --tail 1
(Optional) View access logs in the Container Service for Kubernetes console.
If you use an Alibaba Cloud Container Service for Kubernetes (ACK) cluster, you can also view access logs in the ACK console.
Log on to the ACK console. In the navigation pane on the left, choose Clusters.
On the Clusters page, click the name of the target cluster. In the navigation pane on the left, choose .
On the Pods page, click the name of the target pod, and then click the Logs tab at the bottom of the page to view the access log.
Set the log output format
This feature is available only for ASM instances of version 1.20.6.36 or later. For more information about how to upgrade an instance, see Upgrade an ASM instance.
In the Log Settings area, set Log Output Format to JSON or TEXT as needed.
If you set this option to JSON, the access log is output to the standard output of the container as a JSON string.
If you set this option to TEXT, the access log is output to the standard output of the container as a plain text string.
Customize the log format
In the Log Settings area, select fields as needed, modify custom field information, or click the
icon to the right of the log fields at the bottom to add a log field.You can customize the log format only after you enable Enable Log Output. In the Log Format area, the default log fields are required and cannot be modified. Log fields can retrieve values from request headers, response headers, or Envoy built-in values.
For example, to print the accept-encoding header of a request, set accessLogFormat key to accept-encoding, Type to Request Properties, and accessLogFormat value to Accept-Encoding.

Run the following command to view the logs of the data plane component in the service mesh.
kubectl logs httpbin-5c5944c58c-w**** -c istio-proxy --tail 1|grep accept-encoding --color=autoThe value of the Accept-Encoding header that you added in Step 1 is output to the access log.
Log filtering
Below the Log Settings area, select Enable Log Filter and enter a filtering expression in the text box. Access logs for requests that do not match the expression are not output.
For example, to output logs only for requests with a Response HTTP Status >=400, use the expression response.code >= 400. For more information, see CEL expressions and common fields.
CEL expressions and common fields
The log filtering expression is a standard Common Expression Language (CEL) expression. The following table describes the common fields for CEL expressions. For more information, see CEL and Envoy.
Attribute | Type | Description |
request.path | string | The path of the request. |
request.url_path | string | The path of the request, without the query string. |
request.host | string | The hostname part of the URL. |
request.method | string | The method of the request. |
request.headers | map<string, string> | All request headers, indexed by the lowercase header name. |
request.useragent | string | The value of the User-Agent header. |
request.time | timestamp | The time when the first byte of the request arrives. |
request.id | string | The ID of the request. |
request.protocol | string | The protocol of the request. Valid values: |
request.query | string | The query string in the request URL. |
response.code | int | The return code of the HTTP response. |
response.code_details | string | Details about the response code. |
response.grpc_status | int | The gRPC status code in the response. |
response.headers | map<string, string> | All response headers, indexed by the lowercase header name. |
response.size | int | The size of the response body, in bytes. |
response.total_size | int | The total size of the response message, in bytes. |
Metric settings
Metric settings include enabling or disabling metric generation and metric dimensions.
Enable or disable metric generation
Metrics are divided into client-side metrics and server-side metrics.
Client-side metrics: Metric data generated when the Envoy proxy acts as a client to initiate requests. This includes:
Sidecar egress traffic (traffic from an application that accesses other applications through a sidecar proxy).
Gateway traffic.
Server-side metrics: Metric data generated when the Envoy proxy acts as a server to receive requests. This includes:
Sidecar ingress traffic (traffic from other applications that access the proxied application through a sidecar).
Waypoint traffic.
In the Client-side Metrics (Gateway and Sidecar Outbound) or Server-side Metrics (Sidecar Inbound) column of the Metric Settings area, select or clear the Enable checkbox for a target metric as needed.
If you enable a metric, the Envoy proxy on the data plane of the service mesh exposes the metric through the
/stats/prometheuspath on port 15020.If you disable a metric, the metric is not exposed through the port.
Run the following command to view the metrics exposed by the Envoy proxy.
You can run the curl command in the Envoy proxy container using kubectl to access the
/stats/prometheuspath on the local port 15020 and view the exported metrics.kubectl exec httpbin-5c5944c58c-w**** -c istio-proxy -- curl 127.0.0.1:15020/stats/prometheus|head -n 10Sample output:
# TYPE istio_agent_cert_expiry_seconds gauge istio_agent_cert_expiry_seconds{resource_name="default"} 46725.287654548 # HELP istio_agent_endpoint_no_pod Endpoints without an associated pod. # TYPE istio_agent_endpoint_no_pod gauge istio_agent_endpoint_no_pod 0 # HELP istio_agent_go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE istio_agent_go_gc_duration_seconds summary istio_agent_go_gc_duration_seconds{quantile="0"} 5.0149e-05 istio_agent_go_gc_duration_seconds{quantile="0.25"} 9.8807e-05 ......
Metric dimensions
Metric dimensions can provide richer information. You can use these dimensions to filter for target metrics in Prometheus. For example, you can use the source_app dimension to filter for metrics where the request client is a specific application.
Edit default dimensions
Edit the default dimensions as follows.
In the Metric Settings area, in the Client-side Metrics (Gateway and Sidecar Outbound) or Server-side Metrics (Sidecar Inbound) column, click Edit dimension for the enabled metric.
In the Customize CLIENT dimension configuration or Customize SERVER dimension configuration dialog box, select or deselect the metric dimensions that you want to export, and click Submit.
For example, if no dimensions are disabled, run the curl command in the Envoy proxy container using kubectl to access the /stats/prometheus path on the local port 15020 and view the exported metrics.
kubectl exec httpbin-5c5944c58c-w**** -c istio-proxy -- curl 127.0.0.1:15020/stats/prometheusFor example, istio_request_bytes_sum (which corresponds to the REQUEST_SIZE metric on the dashboard) contains all the dimensions.
istio_request_bytes_sum{reporter="destination",source_workload="istio-ingressgateway",source_canonical_service="unknown",source_canonical_revision="latest",source_workload_namespace="istio-system",source_principal="spiffe://cluster.local/ns/istio-system/sa/istio-ingressgateway",source_app="istio-ingressgateway",source_version="unknown",source_cluster="c479fc4abd2734bfaaa54e9e36fb26c01",destination_workload="httpbin",destination_workload_namespace="default",destination_principal="spiffe://cluster.local/ns/default/sa/httpbin",destination_app="httpbin",destination_version="v1",destination_service="httpbin.default.svc.cluster.local",destination_canonical_service="httpbin",destination_canonical_revision="v1",destination_service_name="httpbin",destination_service_namespace="default",destination_cluster="c479fc4abd2734bfaaa54e9e36fb26c01",request_protocol="http",response_code="200",grpc_response_status="",response_flags="-",connection_security_policy="mutual_tls"} 18000Modify the default server-side REQUEST_SIZE metric to retain only the response_code dimension. Use kubectl to run a curl command in the Envoy proxy container to access the /stats/prometheus path on local port 15020 and view the exported metrics. You can see that the metric includes only the response_code dimension.
istio_request_bytes_sum{response_code="200"} 16550Add custom dimensions
Add custom dimensions as follows:
In the Client-side Metrics (Gateway and Sidecar Outbound) or Server-side Metrics (Sidecar Inbound) column of the Metric Settings area, click Edit dimension for the enabled metric.
In the Customize CLIENT dimension configuration or Customize SERVER dimension configuration dialog box, under Custom Dimension, edit the dimension's name and value, and then click Submit.
For example, after you edit the custom dimension for the REQUEST_SIZE metric on the server-side and add request_path as the dimension name and request.path as the dimension value, use the kubectl command to run a curl command in the Envoy proxy container to access the /stats/prometheus path on local port 15020 and view the exported metrics. You can see that the metric now contains the custom dimension request_path.
istio_request_bytes_sum{response_code="200",request_path="/spec.json"} 5800You can reduce the memory consumption of Envoy and Prometheus by removing default dimensions that are not required for your business. However, most dimensions are typically retained. Therefore, the Metric Settings area displays only the dimensions that have been removed.
Tracing settings
Tracing settings include sampling percentage and custom tags. Tracing requires consistent reporting configurations across the entire call chain to build a complete trace. If the reporting endpoints or sampling rates are inconsistent, the call chain may be incomplete. For this reason, in versions earlier than 1.24.6.83, you cannot configure tracing at the namespace or workload level. In versions 1.24.6.83 and later, ASM supports namespace-level and workload-level tracing configurations by modifying the Telemetry resource through the Kubernetes API. For more information about how to configure the Telemetry resource, see Telemetry CRD.
Sampling percentage
You can customize the sampling percentage for tracing. This value represents the percentage of requests that trigger tracing reports. A value of 0 disables tracing, and no requests trigger reports.
Custom tags
You can customize the tags for reported tracing analysis spans. In the Tracing Analysis Settings section, click Add Custom Tags, and configure the Name, Type, and Value.
The type can be a static field, request header, or environment variable. The following table describes the types and provides tag configuration examples.
Type | Description | Tag configuration example |
Fixed Value | The value of a static field tag is fixed to the value that you set. |
|
Request Header | The value of a request header tag is the value of the request header that you specify. If the header does not exist in the request, the default value is used as the tag value. For example, get the tag value from the User-Agent header. If the header does not exist, set the tag value to the default value `unknow`. |
|
Environment Variable | An environment variable tag gets its value from a specified environment variable of the workload. If the environment variable does not exist in the workload, the default value is used as the tag value. For example, get the tag value from the ENV environment variable. If the environment variable does not exist, set the tag value to the default value `unknow`. |
|