Simple Log Service allows you to collect logs from multiple servers to one Logstore. The servers can belong to a machine group or multiple machine groups. After you apply a Logtail configuration to a machine group, Simple Log Service delivers the Logtail configuration to all servers in the machine group to collect logs from the servers. This topic describes how to create, view, modify, and delete a machine group in Simple Log Service.
Create a machine group
Prerequisites
A project is created. For more information, see Create a project.
Logtail is installed on your server. For more information, see Install Logtail on a Linux server or Install Logtail on a Windows server. If you use an Elastic Compute Service (ECS) instance that resides in the same region as your Simple Log Service project, Simple Log Service can automatically install Logtail when you create a Logtail configuration. For more information, see Install Logtail on ECS instances.
A user identifier is configured for your server. For more information, see Configure a user identifier. If your server and Simple Log Service project belong to the same Alibaba Cloud account, you do not need to configure a user identifier for your server.
Procedure
Simple Log Service allows you to create a machine group by using IP addresses or custom identifiers. Creating an IP address-based machine group is easier compared with creating a custom identifier-based machine group. However, we recommend that you create a machine group by using custom identifiers because of the following benefits:
If the servers of your machine group reside in custom network environments such as virtual private clouds (VPCs), the IP addresses of the servers may conflict. In this case, Logtail fails to collect data. You can create a machine group by using custom identifiers to prevent this issue.
You can flexibly scale a machine group by using custom identifiers. If you configure the same custom identifier for new servers that you want to add to a machine group, Simple Log Service automatically identifies the custom identifier and adds the servers that have the same custom identifier to the machine group. If you no longer need to collect logs from a server, you can delete the custom identifier file on the server. This way, Simple Log Service automatically removes the server from the related machine group.
Create an IP address-based machine group
Obtain the IP address of your server.
Open the app_info.json file on a server on which Logtail is installed and view the value of the
ip
field.The following table describes the paths to the app_info.json file.
Operating system
Logtail
Path to the app_info.json file
Linux
Logtail for 64-bit Linux
/usr/local/ilogtail/app_info.json
64-bit Windows
Logtail for 64-bit Windows
C:\Program Files\Alibaba\Logtail\app_info.json
Logtail for 32-bit Windows
C:\Program Files (x86)\Alibaba\Logtail\app_info.json
32-bit Windows
Logtail for 32-bit Windows
C:\Program Files\Alibaba\Logtail\app_info.json
The
ip
field in the app_info.json file records the server IP address that is automatically obtained by Logtail.
Log on to the Simple Log Service console. In the Projects section, click the project that you want to manage.
In the left-side navigation pane, choose
. In the Machine Groups list, choose .In the Create Machine Group panel, configure parameters and click OK. The following table describes the parameters.
Parameter
Description
Name
The name of the machine group. The name must meet the following requirements:
The name can contain only lowercase letters, digits, hyphens (-), and underscores (_).
The name must start and end with a lowercase letter or a digit.
The name must be 2 to 128 characters in length.
ImportantAfter you create a machine group, you cannot change the name of the machine group. Proceed with caution.
Machine Group Identifier
The identifier type of the machine group. Select IP Address.
Machine Group Topic
Optional. The topic of the machine group. The topic is used to identify the logs that are generated by different servers. For more information, see Log topics.
IP Address
The IP address. Enter the IP address that is obtained in Step 1.
ImportantIf you want to add multiple servers to a machine group, we recommend that you manually enter the IP addresses of the servers and separate the IP addresses with line feeds.
A machine group cannot include both Linux and Windows servers. Do not add the IP addresses of Linux and Windows servers to the same machine group.
Create a custom identifier-based machine group
Create a custom identifier file named
user_defined_id
in a specified directory and configure a custom identifier.ImportantA machine group cannot include both Linux and Windows servers. Do not configure the same custom identifier for Linux and Windows servers.
You can configure one or more custom identifiers for a single server and separate the identifiers with line feeds.
The following list describes the paths to the custom identifier file:
Linux: /etc/ilogtail/user_defined_id
Windows: C:\LogtailData\user_defined_id
On a Linux server, if the
/etc/ilogtail/
directory or the/etc/ilogtail/user_defined_id
file does not exist, you must create the directory or file. On a Windows server, if theC:\LogtailData
directory or theC:\LogtailData\user_defined_id
file does not exist, you must also create the directory or file.
Linux
To configure a custom identifier for a Linux server, run the following command:
echo "user-defined-linux-1" > /etc/ilogtail/user_defined_id
To check whether the custom identifier is configured, run the following command:
[root@test-host ~]# cat /etc/ilogtail/user_defined_id user-defined-linux-1
By default, after you create, delete, or modify the user_defined_id file, the new settings take effect within 1 minute. If you want the new settings to immediately take effect, run the following commands to restart Logtail:
/etc/init.d/ilogtaild stop /etc/init.d/ilogtaild start
Windows
To configure a custom identifier for a Windows server, enter
user-defined-windows-1
in theC:\LogtailData\user_defined_id
file and save the file.To check whether the custom identifier is configured, open and view the
C:\LogtailData\user_defined_id
file.By default, after you create, delete, or modify the user_defined_id file, the new settings take effect within 1 minute. If you want the new settings to immediately take effect, perform the following operations to restart Logtail:
Choose
.In the Services dialog box, select the service that you want to manage.
For Logtail V0.x.x.x, select LogtailWorker.
For Logtail V1.0.0.0 or later, select LogtailDaemon.
Right-click the service and select Restart for the settings to take effect.
Container
The custom identifier file is stored in a Logtail container. The file path is specified in the
ALIYUN_LOGTAIL_USER_DEFINED_ID
environment variable of the Logtail container. You can run thedocker inspect ${logtail_container_name} | grep ALIYUN_LOGTAIL_USER_DEFINED_ID
command to view the file path.Log on to the Simple Log Service console. In the Projects section, click the project that you want to manage.
In the left-side navigation pane, choose
. In the Machine Groups list, choose .In the Create Machine Group panel, configure parameters and click OK. The following table describes the parameters.
Parameter
Description
Name
The name of the machine group. The name must meet the following requirements:
The name can contain only lowercase letters, digits, hyphens (-), and underscores (_).
The name must start and end with a lowercase letter or a digit.
The name must be 2 to 128 characters in length.
ImportantAfter you create a machine group, you cannot change the name of the machine group. Proceed with caution.
Machine Group Identifier
The identifier type of the machine group. Select Custom Identifier.
Machine Group Topic
Optional. The topic of the machine group. The topic is used to identify the logs that are generated by different servers. For more information, see Log topics.
Custom Identifier
The custom identifier. Enter the custom identifier that is configured in Step 1.
View a machine group
In the Machine Groups list, click the machine group that you want to manage. On the Machine Group Configurations page, you can view the configuration of the machine group and the server status.
If the value in the Heartbeat column for a server is OK, Logtail on the server is connected to Simple Log Service.
If the value in the Heartbeat column for a server is FAIL, an error occurs. For more information about how to troubleshoot the error, see How do I troubleshoot an error related to a Logtail machine group in a host environment?
ImportantApproximately 2 minutes are required to create a machine group. If the machine group is not created, the heartbeat status of the machine group is FAIL. In this case, click Refresh 2 minutes later.
Modify a machine group
In the Machine Groups list, click the machine group that you want to manage. In the upper-right corner of the Machine Group Configurations page, click Modify.
In the Machine Group Information section, modify the Machine Group Identifier and Machine Group Topic parameters. If you created a custom identifier-based machine group, you can also modify the Custom Identifier parameter. If you created an IP address-based machine group, you can also modify the IP Address parameter.
In the Manage Configuration section, add a Logtail configuration to the machine group or remove an applied Logtail configuration from the machine group.
ImportantAfter you add a Logtail configuration to the machine group, the Logtail configuration is delivered to Logtail that is installed on each server in the machine group.
After you remove a Logtail configuration from the machine group, the Logtail configuration is removed from Logtail that is installed on each server in the machine group.
After the machine group is modified, click Save.
Delete a machine group
In the Machine Groups list, find the machine group that you want to manage and choose
.In the dialog box that appears, enter the name of the machine group and click Confirm Deletion.
References
You can create a Logtail configuration in Simple Log Service. For more information, see Collect text logs from servers.
You can manage machine groups. The following list describes the API operations that you can call to manage machine groups: