All Products
Search
Document Center

Simple Log Service:Create a custom identifier-based machine group

Last Updated:Mar 06, 2024

If you want to collect logs from servers, you must create a machine group and add the servers to the machine group. If you define a machine group by using IP addresses, address conflicts may occur and log collection may be affected. To prevent address conflicts, you can define a machine group by using a custom identifier to automatically identify and add new servers. This topic describes how to create a custom identifier-based machine group.

Prerequisites

Scenarios

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.

  • If you want to add multiple servers to a machine group, you need to only configure the same custom identifier for new servers that you want to add to the machine group. Simple 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 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, enter userdefined 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, enter userdefined_windows in the C:\LogtailData\user_defined_id file and save the file.

  3. Log on to the Simple Log Service console.

  4. In the Projects section, click the project that you want to manage.

  5. In the left-side navigation pane, choose Resources > Machine Groups.

  6. On the right of Machine Groups, choose 机器组 > Create Machine Group.

  7. 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.

    Machine Group Identifier

    The identifier 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. The identifier must be the same as the value that you specified in Step 2.

  8. View the status of the machine group.

    1. In the Machine Groups list, click the machine group that you want to manage.

    2. 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 whose custom identifier is the same.

        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 the custom identifier as userdefined for the server. Then, you can view the IP address of the server that you added 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 How do I troubleshoot an error that is related to a Logtail machine group in a host environment?

        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.

      机器组状态

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 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.