You can configure Simple Log Service (SLS) to collect logs from Elastic Algorithm Service (EAS) services deployed in a resource group. These logs, including standard output or custom files, are sent to a target Logstore. This topic describes how to configure log collection for public and dedicated resource groups.
Prerequisites
Before you begin, ensure you have activated Simple Log Service (SLS) and created a Project and a Logstore. For more information, see Collect and analyze text logs from ECS instances.
Step 1: Create a machine group for the resource group
Public resource group
For services deployed in a public resource group, you must create a machine group manually.
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

In the left-side navigation pane, choose .
On the right side of Machine Groups, choose .
Create a machine group using a custom identifier.
ImportantThe dedicated custom identifier for the EAS service is
eas-log-group-{region_id}. For example, the custom identifier for Zhangjiakou iseas-log-group-cn-zhangjiakou.
After the service is deployed, open the Machine Group Configuration page. In the Machine Group Status list, you can view the heartbeat status of the instances. OK indicates the machine group is running properly.
NoteIf no service is deployed, the instance list is empty.

Dedicated resource group
To enable log delivery to SLS for a dedicated resource group, perform the following steps in the EAS console.
-
Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Elastic Algorithm Service (EAS).
On the Resource Group tab, click a resource group name to open its details page.
On the dedicated resource group details page, click Configure SLS.

In the Configure Log Service Settings dialog box, select the SLSProject and logstore, and then click OK.
Parameter
Description
SLSProject
A resource management unit in Simple Log Service for resource isolation and control. If no Project is available, click Create SLSProject to create one. For more information, see Manage Projects.
logstore
A unit in Simple Log Service for collecting, storing, and querying log data. If no Logstore is available in the drop-down list, click Create Logstore to create one. For more information, see Create a Logstore.
After the service is activated, a machine group is automatically created in SLS with a name in the format
eas-sls-{resource-id}-mg, for example,eas-sls-eas-r-9u2lq6ij1pk5yvvh****-mg. In this format, resource-id is the resource group ID.EAS also automatically creates a Logtail configuration in the specified Logstore to collect EAS internal logs.
Resource quota
If you use a resource quota (Lingjun), follow these steps to create a machine group.
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

In the left-side navigation pane, choose .
On the right side of Machine Groups, choose .
Create a machine group using a custom identifier.
ImportantThe custom identifier for the resource quota is
eas-log-group-{region_id}-for-resource-quota. For example, the custom identifier for the Zhangjiakou region iseas-log-group-cn-zhangjiakou-for-resource-quota.
After the service is deployed, open the Machine Group Configuration page. In the Machine Group Status list, you can view the heartbeat status of the instances. OK indicates the machine group is running properly.
NoteIf no service is deployed, the instance list is empty.

Step 2: Configure a Logtail
You can configure a Logtail to collect logs. This section describes two common configurations: container standard output and container file logs. For more complex configurations, see Collect text logs from hosts.
Public and dedicated resource groups
Container standard output
Log on to the Simple Log Service console.
In the Import Data section, click K8S-Std-Output(Old).

Select the target Project and Logstore, and then click Next.
Click Use Existing Machine Groups, select the machine group from Step 1 (the one you manually created for a public resource group or the one EAS automatically created for a dedicated resource group), and then click Next.
(Optional) To exclude EAS internal logs when using a custom image, enable Container Filtering in the Input configuration section. Then, add a Container Label Blacklist. Set Label Name to
io.kubernetes.container.nameand Label Value toeasworker.Click Next until the configuration is complete.
Container file logs
In the Import Data section, click Kubernetes - File.

Select the target Project and Logstore, and then click Next.
Click Use Existing Machine Groups, select the machine group from Step 1 (the one you manually created for a public resource group or the one EAS automatically created for a dedicated resource group), and then click Next.
On the Logtail Configurations wizard page, configure the parameters and click Next.
In the Input configuration section, you must configure File Path, which specifies the path of the files to collect. For more information about other parameters, see Collect text logs from Kubernetes containers in DaemonSet mode.
Click Next until the configuration is complete.
Resource quotas
Container standard output
Log on to the Simple Log Service console.
In the Import Data section, click Single Line - Text Logs.
NoteYou can select a different data import method. For example, if you need to match logs using regular expressions, select Regular Expression - Text Logs. If you need to parse logs in JSON format, select JSON - Text Logs. You can also modify the configuration later.

Set Use Case to Host Scenarios and Installation Environment to ECS. Select the machine group that you manually created for the resource quota in Step 1, and then click Next.

In the Logtail configuration, specify the following parameters:

Set File Path to
/var/log/containers-stdout/{container_name}, where {container_name} is the container name. For example, to collect logs from all custom containers, you can set the path to/var/log/containers-stdout/worker*.Set File Name to
*.log.
Click Next until the configuration is complete.
Container file logs
When you deploy a service, specify the directories of the log files to collect in the JSON configuration.
{ "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", } } }In the Import Data section, click Single Line - Text Files.

Set Use Case to Host Scenarios and Installation Environment to ECS. Select the machine group that you manually created for the resource quota in Step 1, and then click Next.

In the Logtail Configuration section, set File Path to a path you specified in the service JSON configuration.

Click Next until the configuration is complete.
Related documentation
After configuring log services for the resource group, you can view the logs in the Logstore. For more information, see Quick start for query and analysis.
If your service needs to access the internet or other access-restricted cloud services, see Configure public network connections and whitelists.
> Create Machine Group