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.
If your server belongs to a different Alibaba Cloud account from your Simple Log Service project, or if your server is from a third-party cloud service provider or in a data center, a custom identifier is configured for the server. For more information, see Configure a user identifier.
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 a custom identifier-based machine group
A 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.
Configure a custom identifier.
Linux
Log on to the Linux server on which Logtail is installed and run the following command to configure a custom identifier.
NoteIf the
/etc/ilogtail/
directory does not exist, create the directory.echo "user-defined-1" > /etc/ilogtail/user_defined_id
Optional. Run the following command to check whether the custom identifier is configured. If
user-defined-1
is returned, the custom identifier is configured.cat /etc/ilogtail/user_defined_id
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
Log on to the Windows server on which Logtail is installed. Create a file named
user_defined_id
in theC:\LogtailData
directory, enteruser-defined-1
in the user_defined_id file, and then save the file.NoteIf the
C:\LogtailData
directory does not exist, create the directory.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 configured custom identifier. Example:
user-defined-1
.
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 theip
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 theapp_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 automatically obtained by Logtail.
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.
View the configuration of 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 machine group-related settings in the Machine Group Information, Machine Group Status, and Manage Configuration sections.
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 may occur because the configuration of the machine group does not take effect. Approximately 2 minutes are required to create a machine group. If the value in the Heartbeat column is still FAIL after 2 minutes, the error may be caused by other configuration issues. To troubleshoot the error, see How do I troubleshoot an error that is related to a Logtail machine group in a host environment?
Modify the machine group information
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.
You can modify the following parameters in the Machine Group Information section in Simple Log Service:
Machine Group Identifier
Machine Group Topic
Custom Identifier or IP Address
After you modify the machine group information, click Save.
Apply a Logtail configuration to a specific 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 Manage Configuration section, select a Logtail configuration and click the
>
icon to move the Logtail configuration from the All Logtail Configurations section to the Applied Logtail Configs section.ImportantAfter you add a Logtail configuration to a 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 a machine group, the Logtail configuration is removed from Logtail that is installed on each server in the machine group.
After you modify the machine group, 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: