tencent cloud

Tencent Kubernetes Engine

Release Notes and Announcements
Release Notes
Announcements
Release Notes
Product Introduction
Overview
Strengths
Architecture
Scenarios
Features
Concepts
Native Kubernetes Terms
Common High-Risk Operations
Regions and Availability Zones
Service Regions and Service Providers
Open Source Components
Purchase Guide
Purchase Instructions
Purchase a TKE General Cluster
Purchasing Native Nodes
Purchasing a Super Node
Getting Started
Beginner’s Guide
Quickly Creating a Standard Cluster
Examples
Container Application Deployment Check List
Cluster Configuration
General Cluster Overview
Cluster Management
Network Management
Storage Management
Node Management
GPU Resource Management
Remote Terminals
Application Configuration
Workload Management
Service and Configuration Management
Component and Application Management
Auto Scaling
Container Login Methods
Observability Configuration
Ops Observability
Cost Insights and Optimization
Scheduler Configuration
Scheduling Component Overview
Resource Utilization Optimization Scheduling
Business Priority Assurance Scheduling
QoS Awareness Scheduling
Security and Stability
TKE Security Group Settings
Identity Authentication and Authorization
Application Security
Multi-cluster Management
Planned Upgrade
Backup Center
Cloud Native Service Guide
Cloud Service for etcd
TMP
TKE Serverless Cluster Guide
TKE Registered Cluster Guide
Use Cases
Cluster
Serverless Cluster
Scheduling
Security
Service Deployment
Network
Release
Logs
Monitoring
OPS
Terraform
DevOps
Auto Scaling
Containerization
Microservice
Cost Management
Hybrid Cloud
AI
Troubleshooting
Disk Full
High Workload
Memory Fragmentation
Cluster DNS Troubleshooting
Cluster kube-proxy Troubleshooting
Cluster API Server Inaccessibility Troubleshooting
Service and Ingress Inaccessibility Troubleshooting
Common Service & Ingress Errors and Solutions
Engel Ingres appears in Connechtin Reverside
CLB Ingress Creation Error
Troubleshooting for Pod Network Inaccessibility
Pod Status Exception and Handling
Authorizing Tencent Cloud OPS Team for Troubleshooting
CLB Loopback
API Documentation
History
Introduction
API Category
Making API Requests
Elastic Cluster APIs
Resource Reserved Coupon APIs
Cluster APIs
Third-party Node APIs
Relevant APIs for Addon
Network APIs
Node APIs
Node Pool APIs
TKE Edge Cluster APIs
Cloud Native Monitoring APIs
Scaling group APIs
Super Node APIs
Other APIs
Data Types
Error Codes
TKE API 2022-05-01
FAQs
TKE General Cluster
TKE Serverless Cluster
About OPS
Hidden Danger Handling
About Services
Image Repositories
About Remote Terminals
Event FAQs
Resource Management
Service Agreement
TKE Service Level Agreement
TKE Serverless Service Level Agreement
Contact Us
Glossary

Custom Nginx Ingress Log

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-09-28 21:40:46
By integrating CLS, TKE provides a complete set of productized capabilities to collect and consume Nginx Ingress logs. For more information, see Nginx-ingress Log Configuration. If the default log index setting does not meet your needs, you can customize the setting. This document describes how to modify the log index setting of Nginx Ingress.

Prerequisites

1. Nginx Ingress v1.1.0 or later is used. To view the version of the Nginx Ingress add-on, log in to the TKE console and choose Cluster details > Add-on management.
Note:
Only Nginx Ingress v1.1.0 or later supports this feature. For earlier versions, such as Nginx Ingress v1.0.0, the add-on will roll back the log index setting modified by users.

2. The Nginx Ingress instance is on v0.49.3 or later. To view the version, log in to the TKE console, choose Cluster details > Services and Routes > NginxIngress, and click View YAML on the right of the target instance. In the YAML file, the ccr.ccs.tencentyun.com/paas/nginx-ingress-controller image must be on v0.49.3 or later.

3. You have enabled the logging feature of Nginx Ingress as instructed in Nginx-ingress Log Configuration.

Directions

Note
To modify the log structure, you need to understand the log stream of Nginx Ingress, which consists of log output, collection, indexing, and configuration. Here, if log output or collection is missing or incorrectly configured, log structure modification will fail.

Step 1. Modify the log output format of the Nginx Ingress instance

The log configuration of the Nginx Ingress instance is in the master configuration ConfigMap named in the format of Instance Name-ingress-nginx-controller. In the ConfigMap, you need to modify the log-format-upstream key.


Sample

Add two consecutive strings $namespace and $service_name to the end of a log.

For more information about fields in Nginx Ingress logs, see Log format.

Step 2. Modify the format for collecting and reporting cluster logs to Agent

The cluster log collection rules are in a resource object of the logconfigs.cls.cloud.tencent.com type. Log in to the TKE console, choose Cluster details > Kubernetes resource manager, find the Instance Name-ingress-nginx-controller resource object, and click Edit YAML to modify it.

You need to modify the following fields:
beginningRegex: Regular expression to match the start of a log.
keys: Log fields.
logRegex: Regular expression to match the end of a log.
The regular expressions match the Nginx log row format. We recommend you add the fields to the existing Nginx log format, declare them at the end of keys, and add their regular expression parsing results to the end of beginningRegex and logRegex respectively.

Sample

Add two keys in Step 1 to the end of keys and add the regular expression strings to the end of beginningRegex and logRegex respectively:


(Optional) Step 3. Modify the log index format of CLS

To search for a field, you need to add the index of the new field in the corresponding log topic in the CLS console as instructed in Configuring Index. Then, all collected logs can be searched for by the index.


Restoring the Initial Settings

As log rule modification is complicated and involves regular expressions, any incorrect step can cause log collection failure. If a log collection error occurs, we recommend you restore to the initial log collection capabilities by disabling the log collection feature and then enabling it again.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan