Help Center/ Cloud Container Engine/ User Guide/ Observability/ Logging/ Collecting NGINX Ingress Controller Logs
Updated on 2024-11-12 GMT+08:00

Collecting NGINX Ingress Controller Logs

The Cloud Native Logging add-on can collect the logs of the NGINX Ingress Controller add-on. You can use the logs to analyze traffic changes and obtain service traffic characteristics for service decision making.

Constraints

  • The NGINX Ingress Controller add-on of version 2.2.82 or later, 2.6.32 or later, or 3.0.8 or later must been installed in the cluster.
  • The Cloud Native Logging add-on of version 1.6.0 or later must be installed in the cluster.

Billing

LTS does not charge you for creating log groups and offers a free quota for log collection every month. You pay only for log volume that exceeds the quota. For details, see Price Calculator.

Step 1: Enabling Log Collection

The NGINX Ingress Controller add-on has been installed in the cluster, with log collection enabled.

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose Add-ons.
  2. Find the NGINX Ingress Controller add-on and enable Logging.
    • If the add-on has been installed, click Manage, locate the installed add-on instance, and click Edit. Then, enable Logging.

      If multiple add-on instances are installed in the cluster, you need to modify the configuration of each add-on instance to collect logs of all instances.

    • If the add-on is not installed, click Install. Then, enable Logging. Set other parameters as required. For details, see NGINX Ingress Controller.

Step 2: Collecting NGINX Ingress Controller Logs in Logging

To enable log collection for the NGINX Ingress Controller add-on in different scenarios, take the following steps.

If logging is not enabled for a cluster, you can select Collect add-on logs (NGINX Ingress Controller stdout logs) when enabling logging to create the default log collection policy for the NGINX Ingress Controller add-on.

  1. On the CCE console, click the cluster name to access the cluster console. In the navigation pane, choose Logging.
  2. If you are not authorized, obtain required permissions first. Otherwise, skip this step.

    In the displayed dialog box, click Authorize.

    Figure 1 Adding authorization

  3. On the page that is displayed, select the type of logs to be collected and click Enable. Wait for about 30 seconds. The new page is automatically displayed.
    Figure 2 Enabling log collection
    • Stdout logs: You can enable this option as needed. After it is enabled, a log collection policy named default-stdout will be created, which will report stdout logs from all namespaces to LTS.
    • Kubernetes events: You can enable this option as needed. After it is enabled, a log collection policy named default-event will be created, which will report Kubernetes events from all namespaces to LTS.
    • NGINX Ingress Controller stdout logs: This option is mandatory. You need to install the NGINX Ingress Controller add-on and enable logging for it.

      After this option is enabled, a log collection policy named default-nginx-ingress will be created, which will report all NGINX Ingress Controller stdout logs with the collection label from all namespaces to LTS.

If logging has been enabled for a cluster but log collection is not enabled for the NGINX Ingress Controller add-on, you can manually create a log collection policy.

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose Logging.
  2. In the upper right corner, click View Log Collection Policies. All log collection policies in the current cluster are displayed.
  3. Click Create Log Collection Policy. Then, select Collect NGINX Ingress Controller stdout Logs and click OK.
    Figure 3 Creating a log collection policy
  4. (The system automatically creates a log collection policy named default-nginx-ingress.) Go to the Logging page and click the Add-on Logs tab to view the logs reported by the add-on to LTS.
    Figure 4 Viewing logs

Step 3: Viewing NGINX Ingress Controller Logs

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose Logging.
  2. Click the Add-ons Log tab and select the NGINX Ingress Controller add-on. For details about related operations, see LTS User Guide.
    Figure 5 Viewing NGINX Ingress Controller logs

  3. (If multiple add-on instances are installed in the cluster and log collection has been enabled for these instances, logs of all instances will be displayed.) Search for logs by appName.
    The options of appName are as follows:
    • If the NGINX Ingress Controller name is nginx, the value of appName is cceaddon-nginx-ingress-controller.
    • If the NGINX Ingress Controller name is user-defined, for example, {className}, the value of appName is cceaddon-nginx-ingress-{className}-controller.

    The following are example logs of cceaddon-nginx-ingress-controller:

    appName : cceaddon-nginx-ingress-controller

Step 4: Viewing Dashboards of NGINX Ingress

CCE can collect the logs of NGINX Ingress and work with LTS for multi-dimensional analysis. It also provides structured logging and three types of dashboards (monitoring center, access center, and second-by-second monitoring) to meet monitoring requirements in different scenarios.

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose Logging.
  2. Click the Add-on Logs tab and then the Dashboard tab. On the displayed tab, you can select different dashboard templates.
  3. (If multiple add-on instances are installed in the cluster and log collection has been enabled for these instances, logs of all instances will be displayed.) Search for logs by appName.
    The options of appName are as follows:
    • If the NGINX Ingress Controller name is nginx, the value of appName is cceaddon-nginx-ingress-controller.
    • If the NGINX Ingress Controller name is user-defined, for example, {className}, the value of appName is cceaddon-nginx-ingress-{className}-controller.

This dashboard displays basic information about NGINX Ingress in different time dimensions (relative time from now, relative time from last, and specified time), including:

  • Access data: PV, UV, request success rate, average latency, the number of 4XX requests, the number of 404 requests, the number of 429 requests, the number of 5XX requests, the number of 504 requests, status code distribution, traffic, access failure rate, and latency
  • Top statistics: hosts ranked by requests, hosts ranked by latencies, hosts ranked by failure rates, URLs ranked by requests, URLs ranked by latencies, URLs ranked by failure rates, backend severs ranked by requests, backend severs ranked by latencies, and backend severs ranked by failure rates

This dashboard displays access request statistics in different time dimensions (relative time from now, relative time from last, and specified time), including:

  • Data comparison: day-over-day PV, week-over-week PV, day-over-day UV, week-over-week UV, PV/UV today, and PV/UV in past seven days
  • Data distribution: PV distribution (China), PV distribution (global), UV distribution (China), UV distribution (global), average latency distribution (China), average latency distribution (global), device proportion (by terminal), and device proportion (by system)
  • Top statistics: top 10 provinces with the most requests, top 10 cities with the most requests, top 10 hosts with the most requests, top 10 UserAgents with the most requests, top URLs with the most requests, and top IP addresses with the most requests

This dashboard displays NGINX Ingress traffic and application performance in real time, including QPS, success rates, latencies, traffic, status codes, and backend response codes.