After installing LoongCollector, create machine groups to organize servers in a project, define collection configurations with data collection rules, and manually bind configurations to machine groups to deploy the rules.
Machine group
A machine group is a logical group of servers managed as a project resource. Servers connect to machine groups through heartbeats. One configuration can apply to multiple groups, and one group can bind multiple configurations.
SLS supports two types of machine groups:
IP host group
Add server IP addresses directly.
-
Simpler to set up.
-
An IP address conflict or change can cause heartbeat failures, affecting data collection.
User-defined machine group
Configure a custom identifier and add it to an identifier file on the server. Each identifier occupies one line; a server can have multiple identifiers.
-
More complex to configure, but avoids IP address conflicts that can cause collection failures in custom network environments like a VPC.
-
Supports automatic scaling. Configure new servers with the same custom identifier, and Simple Log Service automatically adds them to the machine group. To stop collecting logs from a server, delete its identifier file and the server is automatically removed.
-
Create a separate machine group for each module to classify log data. For example, a website with an HTTP request module, a logic module, and a storage module can use custom identifiers such as
http_module,logic_module, andstore_module, respectively.
Create a machine group
Servers require LoongCollector for heartbeat communication with machine groups. Create the machine group when you Install LoongCollector or complete installation and configuration.
Step 1 (Optional): Configure user identifier
Configure a user identity on the server if either condition applies. Skip this step if your ECS instance and SLS project belong to the same Alibaba Cloud account. This identity authorizes Logtail to collect logs for the Log Service project.
-
The server type is not ECS.
-
The server is an ECS instance, but it is not in the same account as Log Service.
-
Log on to the Log Service console with your Alibaba Cloud account (main account). Hover over the profile icon in the upper-right corner and copy the account ID. If you log on as a RAM user, copy the Alibaba Cloud Account ID.

-
Log on to the target server and create an Alibaba Cloud account ID file.
Linux
-
In the
/etc/ilogtail/usersdirectory, create a file named after the Alibaba Cloud account ID.touch /etc/ilogtail/users/{Alibaba Cloud account ID}Important-
If the
/etc/ilogtail/usersdirectory does not exist, create it manually. -
Changes to user identifiers take effect within one minute.
-
-
To collect logs for multiple Alibaba Cloud accounts, create an account ID file for each account. For example:
touch /etc/ilogtail/users/{Alibaba Cloud account ID 1} touch /etc/ilogtail/users/{Alibaba Cloud account ID 2}
Windows
-
In the
C:\LogtailData\usersdirectory, create a file using the Alibaba Cloud account ID as the filename.-
Use Windows PowerShell.
ni C:\LogtailData\users\{Alibaba Cloud account ID} -
Use Command Prompt (cmd).
type nul > C:\LogtailData\users\{Alibaba Cloud account ID}
-
-
To collect logs for multiple Alibaba Cloud accounts, create an account ID file for each account.
Container environment
For Logtail deployed in an Alibaba Cloud Kubernetes cluster (logtail-ds 1.7.3 or later), set the user identifier on the Container Service for Kubernetes console. Go to the Add-ons page and modify the LogtailDSExternalUserDefinelDs parameter of the logtail-ds component. Manage components.
Note-
To configure a user identifier, provide only the filename, without an extension.
-
You can configure multiple user identifiers on a server, but a Logtail container supports only one.
-
To remove a user identifier, delete the corresponding Alibaba Cloud account ID file from the server.
-
Step 2: Create a machine group
In a Simple Log Service Project, you can create a machine group using either an IP Address or a Custom Identifier. Although an IP Address is simpler, a Custom Identifier is recommended:
-
In custom network environments like a VPC, IP Address conflicts can prevent Logtail from collecting logs. Using a Custom Identifier prevents this issue.
-
Using a Custom Identifier enables elastic scaling for a Machine Groups. When you configure new servers with the same Custom Identifier, Simple Log Service automatically detects and adds them to the Machine Groups. Conversely, to stop collecting logs from a server, delete its user-defined identifier file. Simple Log Service then automatically removes the server from the Machine Groups.
User-defined identifier
Configure a user-defined identifier on the servers for each module and create a separate machine group per module for efficient log classification.
For example, a website with HTTP request, cache, logic, and storage modules can use identifiers such as http_module, cache_module, logic_module, and store_module.
-
A Machine Groups cannot contain both Linux and Windows servers. Do not configure the same Custom Identifier on both Linux and Windows servers.
-
You can configure multiple Custom Identifier on a server. Separate the identifiers with line breaks.
-
Configure a Custom Identifier.
Linux
-
Log on to the Linux server where Logtail is installed and run the following command to configure the Custom Identifier.
NoteIf the
/etc/ilogtail/directory does not exist, create it manually.echo "user-defined-1" > /etc/ilogtail/user_defined_id -
(Optional) Run the following command to verify that the Custom Identifier was configured correctly. The configuration is successful if the command returns
user-defined-1.cat /etc/ilogtail/user_defined_id -
By default, changes to the
user_defined_idfile take effect within one minute. To apply the changes immediately, run the following commands to restart Logtail./etc/init.d/ilogtaild stop /etc/init.d/ilogtaild start
Windows
-
Log on to the Windows server on which Logtail is installed. In the
C:\LogtailDatadirectory, create auser_defined_idfile that containsuser-defined-1.NoteIf the
C:\LogtailDatadirectory does not exist, create it manually. -
By default, changes to the user_defined_id file take effect within one minute. To apply the changes immediately, restart Logtail:
-
Choose .
-
In the Service dialog box, find the appropriate Logtail service.
-
For versions 0.x.x.x, the service is named LogtailWorker.
-
For versions 1.0.0.0 and later, the service is named LogtailDaemon.
-
Right-click the service and choose Restart.
-
Container
The user-defined identifier is configured in the
ALIYUN_LOGTAIL_USER_DEFINED_IDenvironment variable of the Logtail container. You can run thedocker inspect ${logtail_container_name} | grep ALIYUN_LOGTAIL_USER_DEFINED_IDcommand to view the identifier. -
-
Log in to the Log Service console. In the Projects, click the target Project. In the left navigation bar, select . On the Machine Groups page, click to the right of Machine Groups.

-
In the Create Machine Group dialog box, configure the following parameters and click OK.
Parameter
Description
Name
The name of the Machine Groups. The name must meet the following requirements:
-
Must contain only lowercase letters, digits, hyphens (-), and underscores (_).
-
Must start and end with a lowercase letter or a digit.
-
Must be 2 to 128 characters in length.
ImportantThe machine group name cannot be changed after creation.
Machine Group Identifier
Select Custom Identifier.
Machine Group Topic
(Optional) The Machine Group Topic distinguishes log data from different servers.
Custom Identifier
Enter the configured Custom Identifier, such as
user-defined-1. -
IP address
-
Log on to the Log Service console. In the Projects, click the target Project.
-
In the left navigation bar, select . On the Machine Groups page, select to the right of Machine Groups.
-
In the Create Machine Group dialog box, configure the following parameters and click OK.
Parameter
Description
Name
The name of the Machine Groups. The name must meet the following requirements:
-
Must contain only lowercase letters, digits, hyphens (-), and underscores (_).
-
Must start and end with a lowercase letter or a digit.
-
Must be 2 to 128 characters in length.
ImportantThe machine group name cannot be changed after creation.
Machine Group Identifier
Select IP Address.
Machine Group Topic
(Optional) The Machine Group Topic differentiates log data from different servers.
IP Address
Enter the IP address that Logtail automatically detects on the server.
On the server where Logtail is installed, open the
app_info.jsonfile and view the value of theipfield.-
app_info.jsonfile path description -
The
ipfield of theapp_info.jsonfile stores the IP address that Logtail automatically detects.[root@iZ2zexxx ]# cat /usr/local/ilogtail/app_info.json { "UUID" : "Cxxx", "compiler" : "GCC 9.3.1", "hostname" : "iZ2zeixxx", "instance_id" : "xxx_l_172.26.128.15_1730267282", "ip" : "172.26.128.15", "logtail_version" : "1.8.7", "os" : "Linux; 5.10.134-17.2.al8.x86_64; #1 SMP Fri Aug 9 15:49:42 CST 2024; x86_64", "update_time" : "2024-10-30 13:48:02" }
Important-
If you have multiple servers, enter their IP addresses manually. Separate the IP addresses with line breaks.
-
A machine group cannot contain both Linux and Windows servers. Do not add the IP addresses of both Windows and Linux servers to the same Machine Groups.
-
Collection configuration
A collection configuration defines rules for collecting, parsing, filtering, and processing data. It binds to a machine group to apply the rules to all servers in that group. Processing runs on the servers and consumes local resources. It has three parts:
-
global configuration: Contains the Logtail configuration name, log topic, and tags for labeling and classifying collected logs.
-
input configuration: Defines the data source type (file input, container stdout, SQL query, or HTTP input) and specifies the collection path and source details for each type.
-
Processing configuration: Uses processing plugins to parse and format collected data (filtering, desensitization, regex matching, JSON parsing).
Create a collection configuration
A collection configuration must bind to an active machine group before deployment. Create one based on the data source type: Log data collection.
Modify a collection configuration
Always modify a collection configuration at its source. Changes made through a different channel can be overwritten during maintenance operations like Pod recreation or component updates, causing incorrect log formats and collection interruptions.
Modification guidelines by creation method:
-
Configurations created in the SLS console, CLI, or SDK: Modify directly with the same tool.
-
Configurations created using the Container Service console or container environment variables: Modify the container environment variables, such as
aliyun_logs_*. For parameter details, see Collect container logs from an ACK cluster. Modification in the SLS console is not supported.-
Environment variables support only basic collection path settings, not advanced parameters or processing plugins. To use advanced features, delete the current environment variables and collection configuration, then recreate it using the SLS console, SDK, CLI, or a CRD.
-
If you later added processing plugins or advanced parameters in the SLS console, a Pod recreation or component update can overwrite those changes. Migrate your configuration promptly.
-
-
Configurations created using a CRD: Directly edit the corresponding CR, such as
AliyunPipelineConfig. For parameter details, see AliyunPipelineConfig parameters. Modification in the SLS console is not supported.-
If you modified an
AliyunPipelineConfig-based configuration in the SLS console, all changes revert within 30 minutes. Verify your configuration meets expectations. -
If you modified an
AliyunLogConfig-based configuration in the SLS console, a Pod recreation or component update can overwrite those changes. Update the CR promptly and consider upgrading toAliyunPipelineConfig.
-
Machine groups and collection configurations
SLS supports many-to-many bindings between collection configurations and Machine Groups. Configurations bind to machine groups, not directly to servers. When you add or remove servers, SLS automatically applies or removes the bound configurations. Servers running different operating systems cannot share a Machine Groups.
Machine group association scenarios
Collect logs from multiple directories
Scenario: Collect logs from /var/log/messages and /opt/app/logs/*.log and send them to the same LogStore.
Solution:
-
In the target LogStore, create two collection configurations with the paths
/var/log/messagesand/opt/app/logs/*.log. -
Apply both collection configurations to the same machine group.
-
Log Service collects data from the paths
/var/log/messagesand/opt/app/logs/*.logon all servers in the machine group into the target LogStore.
Collect logs for multiple Logstores
Requirement: Send different log types from one server to different Logstores.
Solution:
-
Create a separate collection configuration for each destination Logstore.
If multiple configurations collect from the same file, enable the Allow a file to be collected multiple times switch in the input configuration. Collect logs from a file multiple times.
-
Apply these collection configurations to the same machine group.
-
SLS sends logs from the servers in the machine group to the corresponding Logstores based on the collection configurations.
Centralize logs from different servers
Requirement: Collect a specific log type from servers across multiple machine groups into one Logstore.
Solution:
-
Create a collection configuration in the destination Logstore.
-
Apply this collection configuration to all machine groups that contain the target servers.
-
SLS collects logs from the servers in the specified machine groups and sends them to the destination Logstore.
Change collection rules on servers
Requirement 1: Replace the collection configuration bound to a machine group.
Solution:
-
Log on to the SLS console. In the Projects list, click the target Project. In the left-side navigation pane, choose . On the Machine Groups page, click the target machine group. On the Machine Group Configurations page, click Modify.
-
In the Manage Configuration panel, view the list of available collection configurations on the left. Select the required collection configurations and move them to the applied list on the right.
Requirement 2: Add or remove servers from an existing collection scope.
Solution:
-
Log on to the SLS console. In the Projects list, click the target Project. In the left-side navigation pane, choose . On the Machine Groups page, click the target machine group. On the Machine Group Configurations page, click Modify.
-
To apply or remove collection configurations, modify the servers in the machine group:
-
For an IP address-based machine group, add or remove IP addresses in the IP Address field. Separate IP addresses with line breaks.
The IP value must be the same as the value of the
ipfield in the /usr/local/ilogtail/app_info.json file on the server. -
For a custom identifier-based machine group, configure the same Custom Identifier on new servers. Simple Log Service automatically detects these servers and adds them to the Machine Groups. If you no longer want to collect logs from a server, delete the identifier file on that server. The server is then automatically removed from the Machine Groups, which enables automatic scaling.
NoteAdding a server to a machine group does not install LoongCollector automatically. Install LoongCollector on the server first.
-
Related references
Optimize collection performance
-
Tune startup parameters: Resolve common collection issues by modifying configurations.
-
Tune processing plugins: Use write processors or data transformation. Comparison of processing plugins, write processors, data transformation, and consumer processors.
> Create Machine Group

