Home / Platform management / Operations center / Logging / Configure the application log collection policy

Configure the application log collection policy

If you only need to view real-time logs of certain applications in the cluster and do not want to store these logs (the collector will discard the corresponding logs), you can refer to the solution provided in this section to set the scope of application logs to stop collecting (cluster, namespace, Pod) and achieve fine-grained control of application log collection.

Prerequisites

The log collection component has been deployed in the cluster.

Stop collecting all application logs under the cluster

You can update the Configuration parameter of the log collection component of the cluster to turn off the switch for collecting application logs and uniformly update the log collection scope of the cluster. When the collection switch of a certain type of log is turned off, all logs of this type on the current cluster will stop being collected.

Stop collecting application logs under the specified namespace

By adding the cpaas.io/log.mute=true label to the specified namespace, you can turn off the collection switch for application logs in that namespace and stop collecting standard output logs and file logs of all Pods under that namespace.

The optional configuration methods are as follows:

Pod log collection was stopped

By adding the cpaas.io/log.mute=true tag to a specified Pod, the log collection switch of the Pod can be turned off, and the standard output logs and file logs of the Pod will no longer be collected.

After logging in to any control node of the cluster, execute the following command line to update the Pod’s tag.

kubectl label pod <Pod Name> -n <Namespace Name> cpaas.io/log.mute=true

Note: If the Pod belongs to a Workload, you can update the labels of all Pods under the Workload by updating the labels of the Workload (Deployments, StatefulSets, DaemonSets, Jobs, CronJobs) and the labels will not be lost when the Pods are rebuilt.

You can update the labels of a Workload in the following way:

  1. In the Container Platform product view, click on the top navigation bar to switch to the namespace where the Pod is located.

  2. In the left navigation bar, click on Workloads > Type of the computing component that the Pod belongs to.

  3. Click on the > Update button on the right side of the computing component with the labels to be updated.

  4. Click on YAML in the upper right corner to switch to the YAML editing view.

  5. Under the spec.template.labels field, add the label cpaas.io/log.mute: 'true'.

    Example:

    spec:
      template:
        metadata:
          namespace: tuhao-test
          creationTimestamp: null
          labels:
            app: spilo
            cpaas.io/log.mute: 'true'
            cluster-name: acid-minimal-cluster
            role: exporter
            middleware.instance/name: acid-minimal-cluster
            middleware.instance/type: PostgreSQL
  6. Click on Update.