This topic describes how to create a custom ID-based machine group in the Log Service console.

Prerequisites

  • A project and a Logstore are created. For more information, see Create a Logtail project and a Logstore.
  • At least one server is available.
    • If Logtail is installed on an ECS instance, you must ensure that the ECS instance and Log Service project share the same Alibaba Cloud account and belong to the same region.
    • If Logtail is installed on an ECS instance purchased by another Alibaba Cloud account, you must configure a user identifier before you create an IP address-based machine group. If Logtail is installed on the server that is provided by another cloud service vendor, or is a local IDC, you must also perform the preceding operation. For more information, see Configure an account ID for a server.
  • Logtail is installed on the server. For more information, see Install Logtail in Linux and Install Logtail in Windows.

Background information

Custom ID-based machine groups offer distinct advantages in the following scenarios:
  • Custom network environments, such as a VPC, where Log Service may be unable to manage Logtail due to conflicts among server IP addresses. The conflicts can be avoided by using the custom ID for the machine group.
  • To add multiple servers to a machine group, you can set the same custom ID for new servers and the machine group. Log Service identifies the custom ID and adds the servers with the same custom ID to the machine group.

Procedure

  1. Set a custom ID for the server.
    • Linux:

      Set the custom ID in the /etc/ilogtail/user_defined_id file.

      For example, if you want to set the custom ID to userdefined, run the following command to edit the file. In the file, enter userdefined.

      # vim /etc/ilogtail/user_defined_id
    • Windows:

      Set the custom ID in the C:\LogtailData\user_defined_id file.

      For example, if you want to set the custom ID to userdefined_windows, run the following command:

      C:\LogtailData>more user_defined_id
      userdefined_windows
    Note
    • Windows and Linux servers are not allowed in the same machine group. You cannot set the same custom ID for the Linux and Windows servers.
    • You can set one or more custom IDs for the same server and separate custom IDs with line breaks.
    • In the Linux server, if the /etc/ilogtail/ directory or the /etc/ilogtail/user_defined_id file does not exist, you can manually create the directory and file. In the Windows server, if the C:\LogtailData directory or the C:\LogtailData\user_defined_id file does not exist, you can also manually create the directory and file.
  2. Log on to the Log Service console.
  3. In the Projects section, click the name of the target project.
  4. In the left-side navigation pane, click Machine Groups.
  5. Click the Machine Groups icon next to Machine Groups, and select Create Machine Group from the shortcut menu.
  6. In the Create Server Group dialog box, set the following required parameters, and then click OK.
    Parameter Description
    Name The name of the machine group. It must be 3 to 128 characters in length, and can contain only lowercase letters, digits, hyphens (-), and underscores (_). The name must start and end with a lowercase letter or digit.
    Note After the machine group is created, its name cannot be changed. Proceed with caution.
    Identifier The identifier of the server. Select Custom ID.
    Topic The topic of the machine group. This topic is used to differentiate log data that is generated in different servers. For more information, see Configure a log topic.
    Custom Identifier Enter the custom IDs that are obtained in step 1.
  7. View the status of the machine group.
    1. In the Machine Groups list, click the name of the target machine group.
    2. On Machine Group Settings page, view the status of the machine group. You can view the list of servers that share the same custom ID. You can also view the heartbeat statuses of these servers.
      • In the Machine Group Status section, the IP addresses of the servers that share the same custom ID are displayed. For example:

        You set the custom ID to userdefined for the machine group, and the IP addresses in the Machine Group Status section are 10.10.10.10, 10.10.10.11, and 10.10.10.12. It indicates that you set the same custom ID for the servers in this machine group. If you want to add a server with the IP address 10.10.10.13 to the machine group, set the custom ID to userdefined for the server. You can view the IP address of the added server in the Machine Group Status section.

      • If the heartbeat status is OK, the server is connected to Logtail. If the status is FAIL, see What can I do if the Logtail client has no heartbeat?.
      Machine group status

Disable a custom ID

If you want to set the identifier parameter to IP Addresses, delete the user_defined_id file. The new configuration takes effect within 1 minute.

  • In Linux, run the following command:
    rm -f /etc/ilogtail/user_defined_id
  • In Windows, run the following command:
    del C:\LogtailData\user_defined_id

Time to take effect

After you add, delete, or modify the user_defined_id file, the new configuration takes effect within 1 minute by default. If you want the configuration to immediately take effect, run the following commands to restart Logtail:
  • Linux:
    /etc/init.d/ilogtaild stop
    /etc/init.d/ilogtaild start
  • Windows:

    Choose Start Menu > Control Panel > Administrative Tools > Services. In the window that appears, right-click LogtailWorker and select Restart from the shortcut menu to apply the configuration.