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.
- At least one server is available.
- If you use an Elastic Compute Service (ECS) instance, you must make sure that the ECS instance belongs to the same Alibaba Cloud account and region as your Log Service.
- If you use an ECS instance that belongs to a different Alibaba Cloud account from your Log Service, you must configure a user identifier before you create a machine group. If you use a server in a data center or from a third-party cloud service provider, you must also configure a user identifier before you create a machine group. For more information, see Configure a user identifier
- Logtail is installed on the servers. For more information, see Install Logtail on ECS instances
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, Log Service cannot manage Logtail. You can create a custom identifier-based machine group to prevent this issue.
- If you want to achieve auto scaling for a machine group, you need to only configure the same custom identifier for new servers that you want to add to the machine group. Log Service identifies the custom identifier and adds the servers that have the same custom identifier to the same machine group.
Procedure
- Create a file named user_defined_id in a specified 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. Important
- Windows 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 custom 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 the 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 the file.
- Linux server Configure the 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 the 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 Log Service console.
- In the Projects section, click the project that you want to view.
- In the left-side navigation pane, choose .
- On the Machine Groups tab, 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. Important After the machine group is created, you cannot change the name of the machine group. Proceed with caution.Identifier The identifier of the machine group. Select Custom ID. Topic The topic of the machine group. The topic is used to differentiate the logs that are generated by different servers. For more information, see Log topics. Custom Identifier The custom identifier of the machine group. The identifier must be the same as the value that you specified in Step 2. For more information, see 2. - View the status of the machine group.
Disable a custom identifier
If you want to change the value of the Identifier parameter to IP Addresses, 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 add, 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.