All Products
Search
Document Center

Container Service for Kubernetes:Enable Tracing Analysis using Xtrace with AlbConfig

Last Updated:Feb 12, 2026

Alibaba Cloud provides Tracing Analysis, a service that offers developers of distributed applications complete trace reconstruction, call volume statistics, and trace topology. Tracing Analysis helps you quickly analyze and diagnose performance bottlenecks in distributed application architectures to improve development and diagnostic efficiency for microservices. To view trace data, you must install the ALB Ingress Controller component for your cluster and enable the Xtrace feature.

Prerequisites

Enable Tracing Analysis for AlbConfig

Step 1: Enable Simple Log Service for the cluster

After you enable Simple Log Service, the cluster automatically creates a Simple Log Service project. For more information, see Collect logs from ACK cluster containers.

Step 2: Get the ID of the Simple Log Service Project for later use

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. Then, in the navigation pane on the left, click Cluster Information.

  3. On the Cluster Information page, click the Basic Information tab. Then, copy and save the ID from the Simple Log Service Project field.

Step 3: Create an AlbConfig

Use an AlbConfig to create an ALB instance and a listener. In the AlbConfig, enable Simple Log Service and access logs for the ALB instance. Then, configure the Xtrace settings in the listener to enable Xtrace and set the sampling algorithm and sample rate.

  1. Create a file named `alb-test.yaml` and copy the following content into the file to create an AlbConfig.

    Note

    When you reuse an existing ALB instance and want to enable Simple Log Service through the AlbConfig, you must set the forceOverride field to true to forcibly overwrite the ALB instance properties. For more information, see Reuse an existing ALB instance.

    apiVersion: alibabacloud.com/v1
    kind: AlbConfig
    metadata:
      name: alb-demo
    spec:
      config:
        name: alb-test
        addressType: Intranet
        zoneMappings: # The specified vSwitch must be in a zone supported by ALB and in the same VPC as the cluster. For high availability, select at least two vSwitches in different zones.
        - vSwitchId: vsw-2vc82nndnoo********** # Set the ALB vSwitch ID as needed.
        - vSwitchId: vsw-2vc30f5mlhs**********
        accessLogConfig:
          logProject: "k8s-log-xz92lvykqj1siwvif****" # Use the actual Simple Log Service Project obtained.
          logStore: alb_xz92lvykqj1siwvif**** # The logStore name must start with "alb_" (using an underscore). If the specified logStore does not exist, the system automatically creates it.
      listeners:
      - port: 80
        protocol: HTTP
        logConfig:
          accessLogRecordCustomizedHeadersEnabled: false
          accessLogTracingConfig: # Xtrace configuration parameters.
            tracingEnabled: true  # Xtrace switch for the listener. The default value is false. To enable Xtrace, set this parameter to true.
            tracingSample: 9999   # Xtrace sample rate for the listener. Value range: 1 to 10000. This parameter takes effect only when tracingEnabled is true.
            tracingType: Zipkin   # Xtrace sampling algorithm for the listener. Set to Zipkin. This parameter takes effect only when tracingEnabled is true.
    Note
    • For information about how to create a vSwitch, see Create and manage vSwitches.

    • You can modify Xtrace configurations only after you enable Simple Log Service access logs for the instance.

  2. Run the following command to create the AlbConfig.

    kubectl apply -f alb-test.yaml

    Expected output:

    albconfig.alibabacloud.com/alb-demo created

Step 4: Create an IngressClass

  1. Create a file named `alb.yaml` and copy the following content into the file to create an IngressClass.

    apiVersion: networking.k8s.io/v1
    kind: IngressClass
    metadata:
      name: alb
    spec:
      controller: ingress.k8s.alibabacloud/alb
      parameters:
        apiGroup: alibabacloud.com
        kind: AlbConfig
        name: alb-demo
  2. Run the following command to create the IngressClass.

    kubectl apply -f alb.yaml

    Expected output:

    ingressclass.networking.k8s.io/alb created

Step 5: Deploy Services and Configure Ingress Forwarding Rules

  1. Create a file named `cafe-service.yaml` and copy the following content into the file to deploy a deployment named `coffee` and a service named `coffee-svc`.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: coffee
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: coffee
      template:
        metadata:
          labels:
            app: coffee
        spec:
          containers:
          - name: coffee
            image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginxdemos:latest
            ports:
            - containerPort: 80
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: coffee-svc
    spec:
      ports:
      - port: 80
        targetPort: 80
        protocol: TCP
      selector:
        app: coffee
      type: NodePort
  2. Run the following command to deploy the deployment and service.

    kubectl apply -f cafe-service.yaml

    Expected output:

    deployment.apps/coffee created
    service/coffee-svc created
  3. Create a file named `cafe-ingress.yaml` and copy the following content into the file to configure Ingress rules and expose services.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: cafe-ingress 
    spec:
      ingressClassName: alb
      rules:
       - host: demo.domain.ingress.top
         http:
          paths:
          # Configure the context path
          - path: /coffee
            pathType: ImplementationSpecific
            backend:
              service:
                name: coffee-svc
                port: 
                  number: 80
  4. Run the following command to configure the domain name and path for exposing the `coffee` service.

    kubectl apply -f cafe-ingress.yaml

    Expected output:

    ingress.networking.k8s.io/cafe-ingress created

Step 6: Configure Domain Name Resolution

If you configured the spec.rules.host field with your custom domain name when you created an Ingress, you must add a CNAME record for your domain name that resolves to the ALB DNS name. Then, you can access the services using the custom domain name. For more information, see Create and use an ALB Ingress to expose Services to external traffic.

Step 7: Access the Service

Access the service to generate requests with Xtrace IDs.

  1. Run the following command to obtain the ALB instance address (ADDRESS).

    kubectl get ing

    Expected output:

    NAME           CLASS   HOSTS                     ADDRESS                                              PORTS   AGE
    cafe-ingress   alb     demo.domain.ingress.top   alb-u53i28ewt580*****.cn-<Region>.alb.aliyuncs.com   80      16m
  2. Run the following command to access the service.

    curl -H Host:demo.domain.ingress.top http://alb-u53i28ewt580*****.cn-<Region>.alb.aliyuncs.com/coffee

    The expected output is an HTML page with the title Hello World.

Verify Tracing Analysis Effect

  1. Check the Simple Log Service access logs for the ALB instance to confirm that requests contain tagged Xtrace data.

    1. Log on to the ACK console. In the left navigation pane, click Clusters.

    2. On the Clusters page, click the name of the target cluster. Then, in the navigation pane on the left, click Cluster Information.

    3. On the Cluster Information page, click the Basic Information tab. Then, click the link in the Simple Log Service Project field to go to the Simple Log Service console. In the navigation pane on the left, click the LogStore whose name starts with alb_, such as `alb_xz92lvykqj1siwvif****`. On the current page, search for xtrace.

      image

  2. Log on to the Managed Service for OpenTelemetry console.

  3. On the Applications page, select a region in the top navigation bar and click the name of the application.

  4. On the application details page, in the navigation pane on the left, click API Calls. Then, click the Trace tab to view trace data.

    On the Traces tab, you can view up to 100 traces that have the longest duration for the application. For more information about trace data, see Interface Calls.

References