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

  1. 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.
  2. 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, enter userdefined 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, enter userdefined_windows in the C:\LogtailData\user_defined_id file and save the file.

  3. Log on to the Log Service console.
  4. In the Projects section, click the project that you want to view.
  5. In the left-side navigation pane, choose Resources > Machine Groups.
  6. On the Machine Groups tab, choose Machine groups > Create Machine Group.
  7. In the Create Machine Group panel, configure the parameters and click OK. The following table describes the parameters.
    ParameterDescription
    NameThe name of the machine group.
    Important After the machine group is created, you cannot change the name of the machine group. Proceed with caution.
    IdentifierThe identifier of the machine group. Select Custom ID.
    TopicThe 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 IdentifierThe 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.
  8. View the status of the machine group.
    1. In the Machine Groups list, click the machine group.
    2. On the Machine Group Settings 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.

        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 have configured the same custom identifier for the servers in the machine group. If you want to add a new server to the machine group and the IP address of the server is 10.10.10.13, configure the custom identifier as userdefined for the server. 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 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?
        Important If 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.
      Machine Group Status

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
    1. Choose Start Menu > Control Panel > Administrative Tools > Services.
    2. 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.
    3. Right-click the service and select Restart for the configurations to take effect.