Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring Container Log Collection Paths

Updated on 2024-11-05 GMT+08:00

AOM can collect and display container logs. To use this function, first configure a log collection path according to the following procedure.

Precautions

  • The ICAgent only collects *.log, *.trace, and *.out text log files.

Procedure

Adding a Log Policy on CCE

  1. When creating a workload on the CCE console, add a container. Then, expand Log Policies.
  2. Click Add Log Policy. On the displayed page, configure parameters as required. The following uses Nginx as an example.

    Figure 1 Adding a log policy

  3. Set Storage Type to Host Path or Container Path.

    • Host Path: You can mount a host path to a specified container path. Set parameters according to the following table.
      Table 1 Parameters for adding log policies (host path)

      Parameter

      Description

      Storage Type

      Set this parameter to Host Path. You can mount a host path to a specified container path.

      Add Container Path

      *Host Path

      Host path to which a container log file is mounted. Example: /var/paas/sys/log/nginx

      Container Path

      Container path to which a logical data volume is mounted. Example: /tmp
      NOTICE:
      • Do not mount a data volume to a system directory such as / or /var/run. Otherwise, the container becomes abnormal. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. Otherwise, the files will be replaced, causing container startup failures or workload creation failures.
      • If the volume is mounted to a high-risk directory, use an account with minimum permissions to start the container; otherwise, high-risk files on the host may be damaged.
      • AOM collects only the first 20 log files that have been modified recently. It collects files from two levels of subdirectories by default.
      • AOM only collects .log, .trace, and .out text log files in mounting paths.

      Extended Host Path

      Level-3 directory added to the original volume directory or subdirectory. This path enables you to obtain output files of a single pod more easily.

      • None: No extended paths are configured.
      • PodUID: Pod ID.
      • PodName: Pod name.
      • PodUID/ContainerName: Pod ID/container name.
      • PodName/ContainerName: Pod name/container name.

      Collection Path

      Path for collecting logs precisely. Details are as follows:

      • If no collection path is specified, log files in .log, .trace, and .out formats will be collected from the current path by default.
      • If a collection path contains double asterisks (**), log files in .log, .trace, and .out formats will be collected from 5 levels of subdirectories.
      • If a collection path contains an asterisk (*), a fuzzy match is performed.

      Example: If the collection path is /tmp/**/test*.log, all .log files prefixed with test will be collected from /tmp and its 5 levels of subdirectories.

      CAUTION:

      To use the collection path function, ensure that the ICAgent version is 5.12.22 or later.

      Log Dumping

      Log dumping here refers to rolling local log files.

      • Enabled: AOM scans log files every minute. When a log file exceeds 50 MB, it is dumped immediately. A new .zip file is generated in the directory where the log file is located. For a log file, AOM stores only the latest 20 .zip files. When the number of .zip files exceeds 20, earlier .zip files will be deleted. After the dump is complete, the log file in AOM will be cleared.
      • Disabled: If you select Disabled, AOM does not dump log files.
      NOTE:
      • AOM log file rolling is implemented in the copytruncate mode. During configuration, ensure that log files are written in the append mode. Otherwise, file holes may occur.
      • Currently, mainstream log components such as Log4j and Logback support log file rolling. If your log files already support rolling, skip the configuration. Otherwise, conflicts may occur.
      • You are advised to configure log file rolling for your own services to flexibly control the size and number of rolled files.
    • Container Path: Logs will be stored in a container path. No host path needs to be mounted into the container. Set parameters according to the following table.
      NOTE:

      Ensure that the ICAgent version is 5.10.79 or later.

      Table 2 Parameters for adding log policies (container path)

      Parameter

      Description

      Storage Type

      Set this parameter to Container Path.

      Logs will be stored in a container path. No host path needs to be mounted into the container. Ensure that the ICAgent version is 5.10.79 or later.

      Add Container Path

      Container Path

      Container path to which a logical data volume is mounted. Example: /tmp
      NOTICE:
      • Do not mount a data volume to a system directory such as / or /var/run. Otherwise, the container becomes abnormal. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. Otherwise, the files will be replaced, causing container startup failures or workload creation failures.
      • If the volume is mounted to a high-risk directory, use an account with minimum permissions to start the container; otherwise, high-risk files on the host may be damaged.
      • AOM collects only the first 20 log files that have been modified recently. It collects files from two levels of subdirectories by default.
      • AOM only collects .log, .trace, and .out text log files in mounting paths.

      Collection Path

      Path for collecting logs precisely. Details are as follows:

      • If no collection path is specified, log files in .log, .trace, and .out formats will be collected from the current path by default.
      • If a collection path contains double asterisks (**), log files in .log, .trace, and .out formats will be collected from 5 levels of subdirectories.
      • If a collection path contains an asterisk (*), a fuzzy match is performed.

      Example: If the collection path is /tmp/**/test*.log, all .log files prefixed with test will be collected from /tmp and its 5 levels of subdirectories.

      CAUTION:

      To use the collection path function, ensure that the ICAgent version is 5.12.22 or later.

      Log Dumping

      Log dumping here refers to rolling local log files.

      • Enabled: AOM scans log files every minute. When a log file exceeds 50 MB, it is dumped immediately. A new .zip file is generated in the directory where the log file is located. For a log file, AOM stores only the latest 20 .zip files. When the number of .zip files exceeds 20, earlier .zip files will be deleted. After the dump is complete, the log file in AOM will be cleared.
      • Disabled: If you select Disabled, AOM does not dump log files.
      NOTE:
      • AOM log file rolling is implemented in the copytruncate mode. During configuration, ensure that log files are written in the append mode. Otherwise, file holes may occur.
      • Currently, mainstream log components such as Log4j and Logback support log file rolling. If your log files already support rolling, skip the configuration. Otherwise, conflicts may occur.
      • You are advised to configure log file rolling for your own services to flexibly control the size and number of rolled files.

Adding a Log Policy on ServiceStage

Viewing Container Logs

After the log collection paths are configured, the ICAgent collects log files from them. This operation takes about 1 minute to complete. After collecting logs, you can perform the following operations:

  • Viewing Container Log Files

    In the navigation pane, choose Log > Log Files. On the Component tab, select the corresponding cluster, namespace, and component to view log files, as shown in the following figure. For details, see Viewing Log Files.

    Figure 2 Viewing container log files
  • Viewing and Analyzing Container Logs

    In the navigation pane, choose Log > Log Search. On the Component tab, select the corresponding cluster, namespace, component, and file to view and analyze the collected logs. For details, see Searching for Logs.

    Figure 3 Viewing and analyzing container logs

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback