All Products
Search
Document Center

Container Service for Kubernetes:Enable the collection of the control plane logs and audit logs of GitOps

Last Updated:Apr 22, 2024

After you enable GitOps, the logs of the Argo CD control plane and the audit logs of the Argo CD server are collected to Simple Log Service. The Argo CD control plane consists of the Argo CD server and the Argo CD application controller. You can enable the collection of the control plane logs and audit logs of GitOps to view these logs. This topic describes how to enable and disable the collection of the control plane logs and audit logs of GitOps.

Billing

After Simple Log Service is enabled, you are charged pay-as-you-go fees. For more information, see Pay-by-feature.

Prerequisites

Collect control plane logs and audit logs from a Fleet instance

Enable Simple Log Service

Run the following command to create an AliyunLogConfig.

You can customize the project field in the following YAML content. The log controller will automatically create a project that uses the specified name.

If you do not specify the project field, the log controller automatically creates a project named k8s-log-<clusterid> and a Logstore named gitops-argocd-logstore in the project. The Logstore is used to store the logs of Argo CD control planes.

cat << EOF | kubectl apply -f -
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: gitops-argocd-sls-config
  namespace: argocd
spec:
  project: ackone-gitops
  # The log retention period is five days. You can change the value based on your business requirements. 
  lifeCycle: 5
  logstore: gitops-argocd-logstore
  logtailConfig:
    inputType: plugin
    configName: gitops-argocd-sls-config
    inputDetail:
      plugin:
        inputs:
        - detail:
            Stderr: true
            Stdout: true
          type: service_docker_stdout
EOF

Disable Simple Log Service

  1. Run the following command to delete the AliyunLogConfig:

    kubectl delete aliyunlogconfigs.log.alibabacloud.com gitops-argocd-sls-config -n argocd
  2. Log on to the Simple Log Service console and delete the Logstore gitops-argocd-logstore.