All Products
Search
Document Center

Container Service for Kubernetes:Use Simple Log Service to collect container logs from ACK Edge clusters

Last Updated:Oct 08, 2024

ACK Edge is integrated with Simple Log Service. When you create an ACK Edge cluster, you can enable Simple Log Service to collect container logs from the ACK Edge cluster. Kubernetes writes log data to the standard output and text files. This topic describes how to collect container logs from a Container Service for Kubernetes (ACK) Edge cluster by using Simple Log Service.

Step 1: Install Logtail

When you create an ACK Edge cluster, select Enable Log Service to install Logtail. You can also install Logtail for an existing ACK Edge cluster.

Install Logtail when you create a cluster

  1. Log on to the ACK console.

  2. In the left-side navigation pane of the ACK console, click Clusters.

  3. On the Clusters page, click Create Kubernetes Cluster in the upper-right corner.

    In this example, only the steps to enable Simple Log Service are described. For more information about how to create a cluster, see Create an ACK Edge cluster in the console.

  4. On the Component Configurations wizard page, select Enable Log Service to install Logtail.

    After you select the Enable Log Service check box, the system prompts you to create a Simple Log Service project. For more information about projects in Simple Log Service, see Project. You can use one of the following methods to create a Simple Log Service project:

    • Click Select Project and select an existing project to manage the collected log. 使用已有Project

    • Click Create Project to automatically create a project to manage the collected log. The project is named in the k8s-log-{ClusterID} format. ClusterID indicates the unique identifier of the ACK Edge cluster that you created. 创建新Project

  5. After you complete the configuration, click Create Cluster in the lower-right part. In the message that appears, click OK to create the cluster.

    After the ACK Edge cluster is created, you can find the cluster that has Logtail enabled on the Clusters page.

Install Logtail for an existing cluster

  1. Log on to the ACK console.

  2. In the left-side navigation pane of the ACK console, click Clusters.

  3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.

  4. In the left-side navigation pane of the cluster management page, choose Operations > Add-ons and find logtail-ds in the Logs and Monitoring section.

    Note
    • If the version of your ACK Edge cluster is later than 1.18.8-aliyunedge.1, the Simple Log Service component is logtail-ds.

    • If the version of your ACK Edge cluster is 1.18.8-aliyunedge.1 or earlier, the Simple Log Service component consists of alibaba-log-controller and logtail-ds-docker.

  5. Click Install on the logtail-ds card. In the Install logtail-ds dialog box, click OK.

    If an earlier version of the Simple Log Service component is installed, click Upgrade on the card.

Step 2: Configure Simple Log Service when you create an application

You can configure Simple Log Service to collect container logs from an ACK Edge cluster when you create an application.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose Workloads > Deployments.

  3. On the Deployments page, select a namespace from the Namespace drop-down list. Then, click Create from Image in the upper-right corner of the page.

  4. On the Basic Information wizard page, specify Name, Replicas, and Type. Then, click Next to go to the Container wizard page.

    Only parameters related to Simple Log Service are described in the following section. For more information about other application parameters, see Create a Deployment.

  5. In the Log section, configure log collection parameters.

    1. Configure Collection Configuration.

      Important

      After you complete the log collection configuration, you cannot modify the configuration. For more information about how to modify the configuration, see Use CRDs to collect container logs in DaemonSet mode.

      Click the plus sign (+) to add a configuration entry. Each configuration entry consists of Logstore and Log Path in Container (Can be set to stdout).

      • Logstore: Specify the name of the Logstore that is used to store the collected log data. If the Logstore does not exist, ACK automatically creates a Logstore in the Simple Log Service project that is associated with your ACK cluster.

        Note

        The default log retention period of Logstores is 180 days.

      • Log Path in Container (can be set to stdout): the path from which you want to collect log data. A value of /usr/local/tomcat/logs/catalina.*.log indicates that the log files of a Tomcat application are collected.

        Note

        When you set the value to stdout, stdout and stderr are collected.

        All settings are added as configuration entries to the corresponding Logstore. By default, logs are collected in simple mode (by row). If you want to use multi-line mode or other methods to collect log data, see Use the Simple Log Service console to collect container text logs in DaemonSet mode and Use the Simple Log Service console to collect container stdout and stderr in DaemonSet mode.

      采集配置

    2. Set Custom Tag.

      Click the plus sign (+) to add custom tags. Each tag is a key-value pair that is appended to the collected log data. You can use custom tags to mark log data. For example, you can use a tag to denote the application version.

      自定义tag

  6. After you set other parameters, click Next to set advanced settings.

    For more information about the subsequent steps, see Create a stateless application by using a Deployment.

Step 3: View log data

The following example shows how to view the log data of a Tomcat application that is created by using the wizard in the console. The Log data of the Tomcat application is stored in Simple Log Service. You can log on to the Simple Log Service console to view log data collected from the containers. To do this, perform the following operations:

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project that is associated with the Kubernetes cluster to go to the Logstores tab. By default, the project name is in the format of k8s-log-{Kubernetes cluster ID}.

  3. In the Logstore list, find the Logstore that is specified when you configure log collection. Move the pointer over the Logstore name and click the button icon. Then, click Search & Analysis.

    In this example, you can view the stdout of the Tomcat application and text log files of containers. You can also find that custom tags are appended to the collected log data.

What to do next