All Products
Search
Document Center

Container Service for Kubernetes:Analyze nginx-ingress-controller access logs with SLS

Last Updated:Aug 20, 2026

Alibaba Cloud Ingress logs HTTP requests to stdout. Enable log collection when you create a cluster, then use Simple Log Service (SLS) to view Nginx Ingress access-log analytics and monitor real-time Ingress status. This topic describes how to deploy and view Nginx Ingress access logs.

Prerequisites

Before you begin, ensure that you have:

Enable log collection for nginx-ingress-controller

Use the ACK console unless you need to automate setup through a GitOps or CI/CD pipeline.

ACK console

  1. Log on to the ACK console. In the left-side navigation pane, click ACK consoleClusters.

  2. On the Clusters page, click the target cluster. In the left-side navigation pane, choose Operations > Add-ons.

  3. On the Add-ons page, click the Networking tab. On the Nginx Ingress Controller card, click the image.png icon and select Enable Log Collection. Click OK.

CLI

ACK provides a CRD named AliyunLogConfig. When you create an AliyunLogConfig, alibaba-log-controller automatically generates the SLS configuration and updates the dashboards.

Important

Before creating an AliyunLogConfig:

  • If nginx-ingress-controller pods already exist, recreate them after applying the AliyunLogConfig for log collection to take effect.

  • alibaba-log-controller must be version 0.2.0.0-76648ee-aliyun or later. If an AliyunLogConfig already exists after updating the controller, delete and recreate it.

  • This configuration assumes the default ACK log format. If you customized the log format, update the processor_regex section. See Use CRDs to collect container logs in DaemonSet mode.

  1. Create a file named k8s-nginx-ingress.yaml with the following content:

    Set IncludeLabel to Docker labels from docker inspect. io.kubernetes.pod.namespace selects by namespace; io.kubernetes.container.name selects by container. For example, io.kubernetes.pod.namespace: backend-prod collects all containers in that namespace; io.kubernetes.container.name: worker-server targets a specific container. Specify only these two labels. To filter by environment variables, use IncludeEnv or ExcludeEnv. See Use the Simple Log Service console to collect container stdout and stderr in DaemonSet mode.

    Field

    Description

    Modify?

    metadata.namespace

    Namespace of the Ingress controller

    Yes, if not kube-system

    spec.logstore

    SLS Logstore name

    Optional

    IncludeLabel

    Docker labels used to select containers

    Yes, if collecting from a specific namespace

    processor_regex > Regex

    Log parsing regex

    Only if you changed the default log format

    apiVersion: log.alibabacloud.com/v1alpha1
    kind: AliyunLogConfig
    metadata:
      # Unique name for this AliyunLogConfig within the cluster.
      name: k8s-nginx-ingress
      # Set to the namespace of the Ingress controller you want to collect logs from.
      namespace: kube-system
    spec:
      # The SLS Logstore where logs are stored.
      logstore: nginx-ingress
      # Product code — do not change this value.
      productCode: k8s-nginx-ingress
      logtailConfig:
        inputType: plugin
        # Must match metadata.name.
        configName: k8s-nginx-ingress
        inputDetail:
          plugin:
            inputs:
              - type: service_docker_stdout
                detail:
                  IncludeLabel:
                    # Collect logs from the nginx-ingress-controller container.
                    # If multiple Ingress controllers run in your cluster, collecting
                    # by container name may produce duplicate logs. Review the
                    # IncludeLabel behavior before applying.
                    io.kubernetes.container.name: nginx-ingress-controller
                  Stderr: true
                  Stdout: true
            processors:
              - type: processor_regex
                detail:
                  KeepSource: false
                  # Fields extracted from each log line, in order:
                  Keys:
                    - client_ip
                    - x_forward_for
                    - remote_user
                    - time
                    - method
                    - url
                    - version
                    - status
                    - body_bytes_sent
                    - http_referer
                    - http_user_agent
                    - request_length
                    - request_time
                    - proxy_upstream_name
                    - upstream_addr
                    - upstream_response_length
                    - upstream_response_time
                    - upstream_status
                    - req_id
                    - host
                    - proxy_alternative_upstream_name
                  NoKeyError: true
                  NoMatchError: true
                  # Regular expression that maps each capture group to the Keys above.
                  Regex: ^(\S+)\s-\s\[([^]]+)]\s-\s(\S+)\s\[(\S+)\s\S+\s"(\w+)\s(\S+)\s([^"]+)"\s(\d+)\s(\d+)\s"([^"]*)"\s"([^"]*)"\s(\S+)\s(\S+)+\s\[([^]]*)]\s(\S+?(?:,\s\S+?)*)\s(\S+?(?:,\s\S+?)*)\s(\S+?(?:,\s\S+?)*)\s(\S+?(?:,\s\S+?)*)\s(\S+)\s*(\S*)\s*\[*([^]]*)\]*.*
                  SourceKey: content

    The following table describes the fields you are most likely to customize:

  2. Apply the configuration:

    kubectl apply -f k8s-nginx-ingress.yaml

To disable log collection, delete the AliyunLogConfig:

kubectl delete aliyunlogconfig k8s-nginx-ingress -n kube-system

View the access log and dashboards

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project for your ACK cluster (named k8s-log-{cluster-id}).

  3. In the left-side navigation pane, click the Nginx Ingress.png icon, then select a dashboard from the list.

Available dashboards:

Dashboard

Time range

What it shows

Ingress overview

Last 24 h / last 1 min

Traffic volume, latency, error rates, geographic distribution, top URLs

Ingress access center

Last 24 h

UV/PV counts, regional distribution, top browsers and source IPs, mobile breakdown

Ingress monitoring center

Last 1 h

Real-time success rate, error proportions, latency percentiles, top Services by PV and failure rate

Ingress monitoring center for blue-green deployments

Dynamic

Side-by-side comparison of ServiceA and ServiceB metrics for safe rollouts

Ingress exceptions center

Automatic

Anomaly detection powered by SLS machine learning and time series analysis

Ingress overview

Tracks website-level traffic through nginx-ingress-controller. Key metrics:

  • Last 24 hours: page views (PVs), unique visitors (UVs), inbound/outbound traffic, average latency, mobile user proportion, 5xx error proportion, 404 error proportion

  • Last 1 minute: PVs, UVs, request success rate, average latency, P95 latency, P99 latency

  • Trends and distribution: PV trend over 24 hours and 7 days, regional request distribution, top areas and cities, Android/iOS breakdown

  • Top URLs (last 1 hour): 10 URLs by highest PVs, highest latency, most 5xx errors, and most 404 errors

Ingress access center

Request origins and client distribution over 24 hours: UV/PV counts, regional breakdown, top browsers, source IPs, and mobile proportions.

Ingress monitoring center

Real-time metrics from the last hour for detecting and triaging issues:

  • Request success rate, 5xx proportion, 404 proportion, and proportion of requests not forwarded upstream

  • Average latency, P95 latency, P99 latency, and P999 latency

  • Request distribution by status code, and PV proportion per Ingress

  • Top 10 Services by PVs, failure rate, average latency, and total requests

Ingress monitoring center

Ingress monitoring center for blue-green deployments

Side-by-side comparison of ServiceA and ServiceB metrics — PVs, error rates, latency percentiles, and total requests — to detect regressions during blue-green rollouts.

Ingress blue-green deployment monitoring center

Ingress exceptions center

Detects anomalies in nginx-ingress-controller logs using SLS machine learning and time series analysis.

Ingress exceptions center

Configure alerts

Configure alert rules on any dashboard chart, with notifications via email, DingTalk chatbot, webhooks, or SMS.

See Configure an alert rule.

This example creates an alert that fires when the 5xx error proportion exceeds 1%, checked every 5 minutes.

  1. In the Dashboard section, click Ingress Monitoring Center. Hover over the Tip icon in the upper-right corner of the 5XX Proportion chart and click Save as Alert (Old Version).

    Configure alerts

  2. In the Create Alert wizard, set Alert Name, Associated Chart, Frequency, and Trigger Condition. The total field represents the 5xx error proportion; set Trigger Condition to total > 1.

  3. On the Notifications page, select notification channels, configure parameters, and click Submit.

Subscribe to a dashboard

Deliver scheduled dashboard snapshots to an email address or DingTalk group. See Subscribe to a dashboard.

This example subscribes to the Ingress Overview V1.2 dashboard and sends a daily snapshot to a DingTalk group at 10:00.

  1. In the Dashboard section, click Ingress Overview V1.2. Choose Subscribe > Create.

  2. In the Create Subscription wizard, set Frequency to Daily and 10:00. Turn off Add Watermark, then click Next.

  3. On the Notifications page, select WebHook-DingTalk Bot from Notifications and set Request URL to your DingTalk chatbot webhook URL. Click Submit.

Use the Ingress dashboard with ARMS

The Ingress Overview V1.2 dashboard integrates with Application Real-Time Monitoring Service (ARMS) to provide end-to-end trace visibility.

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project for your ACK cluster.

  3. In the left-side navigation pane, click the image icon and select Ingress Overview V1.2 from the Dashboard list.

  4. In the Top 10 Request URLs by Latency section, click a URL in the URL(ARMS Troubleshooting) column to view ARMS trace details for that Service.

Next steps