All Products
Search
Document Center

Platform For AI:Configure log collection for a resource group

Last Updated:Apr 16, 2025

You can configure log collection for a resource group in Platform for AI (PAI). The system will collect the logs generated by Elastic Algorithm Service (EAS) services in the group and store the logs in your Simple Log Service logstore. This topic describes how to configure log collection for a public or dedicated resource group.

Prerequisites

You have activated Simple Log Service and created a project and a logstore.

Step 1: Create a machine group for a resource group

Create a machine group for a public resource group

You need to manually create a machine group for a public resource group.

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project that you want to manage.

    image

  3. In the left-side navigation pane, choose Resources > Machine Groups.

  4. On the right side of Machine Groups, choose 机器组 > Create Machine Group.

  5. Create a machine group by using a custom identifier.

    Important

    The custom identifier for EAS services is eas-log-group-{region_id}. For example, the custom identifier for the China (Zhangjiakou) region is eas-log-group-cn-zhangjiakou.

    image

  6. After the service is deployed, go to the Machine Group Configurations page. In the Machine Group Status section, you can view the heartbeat of instances. OK indicates that the machine group is running as expected.

    Note

    If no services are deployed, the instance list is empty.

    机器组状态

Create a machine group for a dedicated resource group

To create a machine group for a dedicated resource group, you must turn on Configure SLS on the group details page in the PAI console.

  1. Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Enter Elastic Algorithm Service (EAS).

  2. On the Resource Groups tab, click the name of the dedicated resource group to go to the details page.

  3. On the details page of the dedicated resource group, click Configure SLS.

    image

  4. In the Configure Log Service Settings dialog box, configure SLSProject and LogStore, and click OK.

    Parameter

    Description

    SLSProject

    Log Service projects are used to isolate and manage resources in Simple Log Service. If no project is available in the drop-down list, you can click Create SLSProject to create one.

    LogStore

    The Logstore that is used to collect, store, and query log data. If no Logstore is available in the drop-down list, you can click Create Logstore to create one.

    After the configuration is complete, a machine group is automatically created in Simple Log Service. The name of the machine group is in the format of eas-sls-{resource-id}-mg. For example, eas-sls-eas-r-9u2lq6ij1pk5yvvh****-mg.

    EAS automatically creates a Logtail configuration in the specified Logstore to collect logs generated by EAS services.

Create a machine group for a resource quota

If you use Lingjun resources, take the following steps to create a machine group.

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project that you want to manage.

    image

  3. In the left-side navigation pane, choose Resources > Machine Groups.

  4. On the right side of Machine Groups, choose 机器组 > Create Machine Group.

  5. Create a machine group by using a custom identifier.

    Important

    The custom identifier for a resource quota is eas-log-group-{region_id}-for-resource-quota. For example, the custom identifier in the China (Zhangjiakou) region is eas-log-group-cn-zhangjiakou-for-resource-quota.

    image

  6. After the service is deployed, go to the Machine Group Configurations page. In the Machine Group Status section, you can view the heartbeat of instances. OK indicates that the machine group is running as expected.

    Note

    If no services are deployed, the instance list is empty.

    机器组状态

Step 2: Create a custom Logtail configuration

You can create a custom Logtail configuration to collect the desired logs. The following sections describe two configuration items that are frequently used: container standard outputs and container file logs. For more complex configurations, see Collect text logs from servers.

For public or dedicated resource group

Collect container standard outputs

  1. Log on to the Simple Log Service console.

  2. In the Import Data dialog box, click K8S - Stdout and Stderr - Old Version.

    image

  3. Select desired project and Logstore, and click Next.

  4. Click Use Existing Machine Groups. Select the machine group that you created manually or automatically in Step 1. Then, click Next.

  5. (Optional) If you use a custom image to deploy a service and you do not want to collect EAS logs, in the Input Configurations section, turn on Container Filtering and add a Container Label Blacklist. Enter io.kubernetes.container.name for the Label Name and easworker for the Label Value.

  6. Click Next until the configuration is complete.

Collect container file logs

  1. In the Import Data dialog box, click Kubernetes - Object.

    Kubernetes-文件

  2. Select desired project and Logstore, and click Next.

  3. Click Use Existing Machine Groups. Select the machine group that you created manually or automatically in Step 1. Then, click Next.

  4. On the Logtail Configuration wizard page, configure the parameters and click Next.

    You need to configure File Path (of the files to be collected) in the Input Configurations section. For information about other parameters, see Collect text logs from Kubernetes containers in DaemonSet mode.

  5. Click Next until the configuration is complete.

For resource quota

Collect container standard outputs

  1. Log on to the Simple Log Service console.

  2. In the Import Data dialog box, click Single Line - Text Logs.

    Note

    You can use other types based on your requirements. For example, if you need to use regular expressions to match collected logs, select Regular Expression - Text Logs. If you need to parse logs in JSON format, select JSON - Text Logs. You can also change the type after you create the Logtail configuration.

    image

  3. Select Servers for Scenario and ECS for Installation Environment. Select the machine group that you manually created in Step 1. Then, click Nextimage

  4. In the Input Configuration section, enter the following settings:image

    • For File Path, enter /var/log/containers-stdout/{container_name}. For example, if you want to collect logs from all custom containers, you can enter /var/log/containers-stdout/worker*.

    • For File Name, enter *.log.

  5. Click Next until the configuration is complete.

Collect container file logs

  1. When you deploy a service, specify the path of the log files to be collected in JSON.

    {
      "cloud": {
        "logging": {
          "paths": [
            "/home/admin/logs",
            "/home/workspace/logs",
            "/var/log"
          ]
        },
        //Other configurations are omitted
        "networking": {
          "security_group_id": "sg-xxxxx",
          "vswitch_id": "vsw-xxxxx",
          "vpc_id": "vpc-xxxxx",
        }
      }
    }
  2. In the Import Data dialog box, click Single Line - Text Logs.

    image

  3. Select Servers for Scenario and ECS for Installation Environment. Select the machine group that you manually created in Step 1. Then, click Next.image

  4. In the Input Configurations, enter the path that you have specified in the JSON.image

  5. Click Next until the configuration is complete.

References

OSZAR »