Updated on 2024-06-26 GMT+08:00

Monitoring Metrics of NGINX Ingress Controller

You can use Prometheus and Grafana to observe the metrics of NGINX Ingress Controller.

The following uses Prometheus as an example to describe how to view the metrics of NGINX Ingress Controller of a cluster.

  1. Accessing Prometheus

    (Optional) Bind a LoadBalancer Service to Prometheus so that Prometheus can be accessed from external networks.

  2. Monitoring Metrics of NGINX Ingress Controller

    Enable metric collection for NGINX Ingress Controller so that NGINX Ingress Controller metrics are automatically reported.

Prerequisites

  • The cloud native cluster monitoring add-on 3.9.5 or later has been installed in the cluster. For details about this add-on, see Cloud Native Cluster Monitoring.
  • NGINX Ingress Controller 2.5.4 or later has been installed in the cluster, and metric collection has been enabled. For details about this add-on, see NGINX Ingress Controller.

Accessing Prometheus

After the cloud native cluster monitoring add-on is installed, you can deploy workloads and Services. The Prometheus server will be deployed as a StatefulSet in the monitoring namespace.

You can create a public network LoadBalancer Service so that Prometheus can be accessed from external networks.

  1. Log in to the CCE console and click the name of the cluster with Prometheus installed to access the details page. In the navigation pane, choose Services & Ingresses.
  2. Click Create from YAML in the upper right corner to create a public network LoadBalancer Service.

    apiVersion: v1
    kind: Service
    metadata:
      name: prom-lb     # Service name, which is customizable.
      namespace: monitoring
      labels:
        app: prometheus
        component: server
      annotations:
        kubernetes.io/elb.id: 038ff***     # Replace it with the ID of the public network load balancer in the VPC that the cluster belongs to.
    spec:
      ports:
        - name: cce-service-0
          protocol: TCP
          port: 88             # Service port, which is customizable.
          targetPort: 9090     # Default Prometheus port. Retain the default value.
      selector:                # The label selector can be adjusted based on the label of a Prometheus server instance.
        app.kubernetes.io/name: prometheus
        prometheus: server
      type: LoadBalancer

  3. After the Service is created, enter Public IP address of the load balancer:Service port in the address box of the browser to access Prometheus.

    Figure 1 Accessing Prometheus

  4. Choose Status > Targets to view the targets monitored by Prometheus.

    Figure 2 Viewing monitored targets

Monitoring Metrics of NGINX Ingress Controller

Log in to Prometheus and click Graph to view the metrics of NGINX Ingress Controller.

Figure 3 Viewing the metrics of NGINX Ingress Controller
Table 1 Metrics of NGINX Ingress Controller

Metric

Type

Description

nginx_ingress_controller_bytes_sent

Basic metric

Number of bytes sent to the client

nginx_ingress_controller_connect_duration_seconds

Basic metric

Duration for connecting to the upstream server

nginx_ingress_controller_header_duration_seconds

Basic metric

Time required for receiving the first header from the upstream server

nginx_ingress_controller_ingress_upstream_latency_seconds

Basic metric

Upstream service latency

nginx_ingress_controller_request_duration_seconds

Basic metric

Time required for processing a request, in milliseconds

nginx_ingress_controller_request_size

Basic metric

Length of a request, including the request line, header, and body

nginx_ingress_controller_requests

Basic metric

Total number of client requests

nginx_ingress_controller_response_duration_seconds

Basic metric

Time required for receiving the response from the upstream server

nginx_ingress_controller_response_size

Basic metric

Length of a response, including the request line, header, and request body

nginx_ingress_controller_nginx_process_connections

Basic metric

Number of client connections in the {active, reading, writing, or waiting} state

nginx_ingress_controller_nginx_process_connections_total

Basic metric

Total number of connections in the {accepted or handled} state

nginx_ingress_controller_nginx_process_cpu_seconds_total

Basic metric

CPU usage, in seconds

nginx_ingress_controller_nginx_process_num_procs

Basic metric

Number of processes

nginx_ingress_controller_nginx_process_oldest_start_time_seconds

Basic metric

Start time, in seconds elapsed since 00:00:00 on January 1, 1970

nginx_ingress_controller_nginx_process_read_bytes_total

Basic metric

Number of bytes read

nginx_ingress_controller_nginx_process_requests_total

Basic metric

Total number of client requests

nginx_ingress_controller_nginx_process_resident_memory_bytes

Basic metric

Number of bytes of resident memory in use

nginx_ingress_controller_nginx_process_virtual_memory_bytes

Basic metric

Number of bytes of virtual memory in use

nginx_ingress_controller_nginx_process_write_bytes_total

Basic metric

Number of bytes written

nginx_ingress_controller_build_info

Basic metric

A metric with a constant '1' labeled with information about the build

nginx_ingress_controller_check_success

Basic metric

Cumulative count of syntax check operations of NGINX Ingress Controller

nginx_ingress_controller_config_hash

Basic metric

Hash value of running NGINX Ingress Controller

nginx_ingress_controller_config_last_reload_successful

Basic metric

Whether the last configuration reload attempt was successful

nginx_ingress_controller_config_last_reload_successful_timestamp_seconds

Basic metric

Timestamp of the last successful configuration reload

nginx_ingress_controller_ssl_certificate_info

Basic metric

All labels associated with a certificate

nginx_ingress_controller_success

Basic metric

Cumulative count of reload operations of NGINX Ingress Controller

nginx_ingress_controller_orphan_ingress

Basic metric

Status of an orphaned ingress (1 indicates an orphaned ingress).

  • namespace: character string used to identify the namespace of the ingress
  • ingress: ingress name
  • type: status of the ingress. The value can be no-service or no-endpoint.

nginx_ingress_controller_admission_config_size

Basic metric

Size of the tested configuration

nginx_ingress_controller_admission_render_duration

Basic metric

Time required for the admission controller to render an ingress

nginx_ingress_controller_admission_render_ingresses

Basic metric

Length of an ingress rendered by the admission controller

nginx_ingress_controller_admission_roundtrip_duration

Basic metric

Complete duration of the admission controller at the time to process a new event (float seconds)

nginx_ingress_controller_admission_tested_duration

Basic metric

Time required for admission controller tests (float seconds)

nginx_ingress_controller_admission_tested_ingresses

Basic metric

Length of an ingress handled by the admission controller

When NGINX Ingress Controller is heavily loaded, memory leakage occurs when full metric collection is enabled. For details, see the community issue. It has been verified that the memory usage increase can be effectively suppressed after the following metrics are shielded. To prevent service loss caused by memory leakage, NGINX Ingress Controller shields the following metrics by default. We will continue to pay attention to the latest news in the community and fix this issue in a timely manner.

  • nginx_ingress_controller_success
  • nginx_ingress_controller_header_duration_seconds
  • nginx_ingress_controller_ingress_upstream_latency_seconds