Skip to content

Use Logtail to collect logs across Alibaba Cloud accounts

This topic describes how to collect logs from a server across Alibaba Cloud accounts.

Step 1: Create a user identifier file

  1. Log on to an Elastic Compute Service (ECS) instance that belongs to Alibaba Cloud Account B. You must create a user identifier file on each ECS instance of ECS Cluster B.

  2. Run the following command to create a user identifier file.

touch /etc/ilogtail/users/12****456

Step 2: Create a custom identifier-based machine group

  1. Create a custom identifier file for the machine group on an ECS instance. You must create a custom identifier file for the machine group on each ECS instance of ECS Cluster B.

    a.Log on to an ECS instance that belongs to Alibaba Cloud Account B. b.Create a file named /etc/ilogtail/user_defined_id in the specified directory and specify a custom identifier in the /etc/ilogtail/user_defined_id file.

  1. Create a machine group in the Simple Log Service console.

    a.Log on to the Simple Log Service console by using Alibaba Cloud Account A. b.In the Projects section, click the name of the project that you want to manage. c.In the left navigation pane, choose Resource > Machine Group. d.On the Machine Group tab, choose More > Create Machine Group. e.In the Create Machine Group panel, configure the parameters and click OK. The following figure shows the parameters.

  2. Check whether the heartbeat status of each server in the machine group is OK.

    a.In the Machine Group list, click the name of the machine group that you created.。 b.On the Machine Group Configurations page, view the status of the machine group. You can view a list of ECS instances that use the same custom identifier. You can also view the heartbeat status of each ECS instance.。

Step 3: Collect logs

  1. Log on to the Simple Log Service console by using Alibaba Cloud Account A.
  2. In the Import Data section, click Regular Expression - Text Log.
  3. In the Select Logstore step, select a project and a Logstore, and then click Next.
  4. In the Create Machine Group step, click Use Existing Machine Groups.
  5. In the Machine Group Configurations step, select the machine group that you created in Step 2, move the machine group from the Source Machine Group section to the Applied Server Groups section, and then click Next.
  6. Create a Logtail configuration and click Next.
  • For information about the parameters, see [Collect logs in full regex mode].

Important:

  1. Preview data, configure indexes, and then click Next.
  • By default, the full-text indexing feature is enabled for Simple Log Service.You can configure field indexes based on the collected logs in manual mode or automatic mode.For more information, see [Create indexes].

What to do next