Configuring a Log Policy of an Application
ServiceStage allows you to configure a log policy for application components deployed in containers. If a CCE cluster is bound to the component deployment environment, you can view running logs on AOM or collect component running logs to LTS for processing. If no log policy is configured, the system collects standard application output logs by default.
You are advised to directly collect logs to LTS. The function of viewing logs in AOM will be removed soon.
Restrictions
If you want to collect the run logs of the container-deployed component to LTS for processing, there are the following restrictions:
- CCE cluster nodes whose container engine is Docker are supported.
- CCE cluster nodes whose container engine is Containerd are supported. You must be using ICAgent 5.12.130 or later.
- To collect container log directories mounted to host directories to LTS, you must configure the node file path.
- Currently, container file log collection supports only the Overlay2 storage driver, not Device Mapper. Run the following command to check the storage driver type:
docker info | grep "Storage Driver"
Configuring a Log Policy of an Application
- Choose Container Settings.
- Choose Log Collection > Add Log Policy.
- Set the parameters by referring to the following table. Parameters marked with an asterisk (*) are mandatory.
Parameter
Description
Storage Type
Select a log storage type.
- Host Path: Mount a host path to a specified container path.
- Container Path: Logs are exported only to the container path. You do not need to mount the host path. The ICAgent needs to be upgraded to 5.10.79.
*Host Path
This parameter is mandatory when Storage Type is set to Host Path.
Enter the log storage path on the host.
*Container Mounting
- Set Mount Path to the path to which the data storage is mounted.
- Do not mount a data volume to a system directory such as / or /var/run. Otherwise, an exception occurs. An empty directory is recommended. If the directory is not empty, ensure that the directory does not contain any file that affects application startup. Otherwise, the files will be replaced, causing application startup exceptions. As a result, the application fails to be created.
- When the data volume is mounted to a high-risk directory, you are advised to use a low-permission account to start the application; otherwise, high-risk files on the host may be damaged.
- Set Extended Host Path. This parameter is mandatory when Storage Type is set to Host Path.
- None: No extended path is configured.
- PodUID: Pod ID.
- PodName: Pod name.
- PodUID/ContainerName: Pod ID or container name.
- PodName/ContainerName: Pod name or container name.
- Set Collection Path.
After specifying the collection path, you can specify the content to collect. The collection path can be specified if the ICAgent version of the collector is 5.12.22 or later. The following modes are supported:
- 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.
- Set Aging Period.
- Hourly: Log files are scanned every hour. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- Daily: Log files are scanned once a day. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- Weekly: Log files are scanned once a week. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- Click
to set Log Format.
By default, the system collects and displays the logs printed by the program by line. If a complete log occupies multiple lines and you want to collect and display the entire log, you can set Log Format to enable multi-line logs.- Single-line: The system collects logs by line.
- Multi-line: The system collects logs based on the configured matching rules.
Log Segmentation: This parameter is mandatory when Log Format is set to Multi-line. It is used to match the beginning of each log. If you select Log time, the time matching mode is used. If you select Regular expression, the regular expression matching mode is used.
Time Wildcard: Enter the time wildcard when Log Segmentation is set to Log time. For example, if the time format of each log is YYYY-MM-DD hh:mm:ss, set the time wildcard to YYYY-MM-DD hh:mm:ss.
Regular expression: If Log Segmentation is set to Regular expression, enter the regular expression based on the format of the beginning of each log.
- Click OK.
- Determine whether to collect component run logs to LTS by referring to the following table.
Whether to Collect Component Run Logs to LTS
Description
Yes
Select Auto connection to LTS.
The system determines the log collection path based on 3:- If container mounting is configured, logs are delivered to the container file path of LTS.
- If host mounting is configured, logs are delivered to the node file path of LTS.
- If both container and node mounting are configured, only the node mounting path can be retained due to LTS restrictions, and logs are delivered only to the node file path of LTS.
- If you do not configure log collection, the log path is /var/log/* or /var/logs/*, which corresponds to the container file path of LTS.
After a component is configured and deployed, the system automatically generates log group and log stream configurations, and generates access configurations and host groups on the Ingestion Management page of the LTS console.- Log Group: The naming rule is servicestage-{Application ID}. Use the ID of the application to which the component belongs.
- Log Stream: The naming rule is lts-topic-{Component name}. Use the name of the component connected to LTS.
- Ingestion: The naming rule is access-config-{Component name}. Use the name of the component connected to LTS.
- Host Group: The naming rule is k8s-log-{CCE cluster ID}. Use the ID of the CCE cluster where the component connected to LTS is located.
No
Do not select Auto connection to LTS.
- After the component is configured and deployed, you can view running logs on the AOM console. For details, see Viewing Log Files.
- After the component is configured and deployed, you can collect component logs to LTS by referring to Managing Component LTS Logs.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot