KCE provides the log collection service within Kubernetes clusters and sends collected log data to Kingsoft Cloud Log Service (KLog). It enables you to collect, store, analyze, and present business logs, improving your Operations and Maintenance (O&M) management and online troubleshooting efficiency.
You need to manually enable the log collection service for each Kubernetes cluster. KCE deploys a log collection client in the cluster by using a DaemonSet, collects data from log sources, including container standard output logs, container file logs, and host file logs, based on your log collection rules, and sends the data to KLog for statistics and analysis.
Prerequisites
- Resources in your cluster that are to be occupied by the log collection service are verified. The log collection service occupies 0.1 cores to 1 core of the CPU and 100 MB to 500 MB of the memory by default. You can adjust the resource occupation as required.
- All nodes in the cluster can access KLog.
Procedure
Enable the log collection service
- Log in to the KCE console.
- In the left navigation pane, click Log Management.
- On the page that appears, select the region and cluster in which the log collection service is not enabled, and click Apply for install.
- In the Enable Log Collection Service dialog box, click Active.
Configure log collection rules
- Log in to the KCE console.
- In the left navigation pane, click Log Management.
- On the page that appears, select the region and cluster as required and click Create.
- On the Create Log Collection Rule page, set the following parameters:
- Rule Name: the name of the log collection rule, which must be unique in the cluster.
- Log Type: the supported log type. Valid values: Container Standard Output, Container File Path, and Host File Path.
- If you set Log Type to Container Standard Output, logs can be collected from the following sources:
- All Containers: all containers in the cluster.
- Specified Workload: containers that run specified workloads in a namespace.
- If you set Log Type to Container File Path, logs can be collected from the following sources:
- Log files of any specified container in the cluster
- If you set Log Type to Host File Path, logs can be collected from the following sources:
- Log files of any specified node in the cluster. You can add labels to the collected logs in the key-value format for subsequent analysis and classification.
- Log Source: the source from which you collect logs. Set this parameter based on the selected log type.
- Consumer: the log consumer. Only KLog is available. You must specify a project and a log pool for KLog.
View and update log collection rules
- Log in to the KCE console.
- In the left navigation pane, click Log Management.
- On the page that appears, select the region and cluster to view the configured log collection rules.
- To modify a log collection rule, find the log collection rule and click Edit Log Collection Rule in the Operation column to go to the rule modification page.