Simple Log Service allows you to define a machine group by using a custom identifier. This topic describes how to create a custom identifier-based machine group.
Prerequisites
A project and a Logstore are created. For more information, see Create a project and Create a Logstore.
Logtail is installed. For more information, see Install Logtail on a Linux server and Install Logtail on a Windows server. If you use an Elastic Compute Service (ECS) instance that belongs to the same Alibaba Cloud account and region as your Simple Log Service project, you can install Logtail by following the instructions provided in Install Logtail on ECS instances.
A user identifier is configured. If you use an ECS instance that belongs to the same Alibaba Cloud account as your Simple Log Service project, you do not need to configure a user identifier.
Background information
Custom identifier-based machine groups provide benefits in the following scenarios:
If your servers reside in multiple custom network environments such as virtual private clouds (VPCs), the IP addresses of some servers may conflict. In this case, Simple Log Service cannot manage Logtail. You can create a custom identifier-based machine group to prevent this issue.
You can flexibly scale a machine group by configuring the same custom identifier for multiple servers. If you configure the same custom identifier for new servers that you want to add to a machine group, Simple Log Service identifies the custom identifier and adds the servers that have the same custom identifier to the machine group.
Procedure
Create a file named user_defined_id in a specific directory.
Linux server: Create the file in the /etc/ilogtail/user_defined_id directory.
Windows server: Create the file in the C:\LogtailData\user_defined_id directory.
Configure a custom identifier for your servers.
ImportantWindows and Linux servers cannot be added to the same machine group. 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.
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 and file. On a Windows server, if the C:\LogtailData directory or the C:\LogtailData\user_defined_id file does not exist, you must also create the directory and file.
Linux server
Configure a custom identifier in the /etc/ilogtail/user_defined_id file. For example, if you want to configure the custom identifier as
userdefined
, run the following command to edit the file. Then, enteruserdefined
in the file and save the file.vim /etc/ilogtail/user_defined_id
Windows server
Configure a custom identifier in the C:\LogtailData\user_defined_id file. For example, if you want to configure the custom identifier as
userdefined_windows
, enteruserdefined_windows
in the C:\LogtailData\user_defined_id file and save the file.
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 .
On the right side of Machine Groups, choose .
In the Create Machine Group panel, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Name
The name of the machine group.
ImportantAfter the machine group is created, 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
The topic of the machine group. The topic is used to identify logs that are generated by different servers. For more information, see Log topics.
Custom Identifier
The custom identifier of the machine group. Specify the custom identifier that you configured in Step 2.
View the status of the machine group.
In the Machine Groups list, click the machine group that you want to manage.
On the Machine Group Configurations page, view the servers that have the same custom identifier and the heartbeat status of each server.
The Machine Group Status section displays the IP addresses of the servers that have the same custom identifier.
For example, a custom identifier-based machine group is created, the custom identifier is userdefined, and the IP addresses in the Machine Group Status section are 10.10.10.10, 10.10.10.11, and 10.10.10.12. This indicates that you configured the same custom identifier for the servers in the machine group. If you want to add another server to the machine group and the IP address of the server is 10.10.10.13, configure a custom identifier for the server as userdefined. Then, you can view the IP address of the server in the Machine Group Status section.
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 is FAIL, the connection failed. For more information, see What do I do if a Logtail machine group has no heartbeats?
ImportantIf you check the status of a machine group immediately after the machine group is created, the heartbeat may be FAIL because the connection has not taken effect. In this case, click Refresh.
Disable a custom identifier
If you want to change the value of the Machine Group Identifier parameter to IP Address, you must delete the user_defined_id file. The new configurations take effect within 1 minute.
Linux
rm -f /etc/ilogtail/user_defined_id
Windows
del C:\LogtailData\user_defined_id
Effective period
By default, after you create, delete, or modify the user_defined_id file, the new configurations take effect within 1 minute. If you want the new configurations to immediately take effect, run the following commands to restart Logtail:
Linux
/etc/init.d/ilogtaild stop /etc/init.d/ilogtaild start
Windows
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 configurations to take effect.