This topic describes how to use Logtail to collect ECS logs in the Log Service console.
- Install Logtail on your server.
- Configure a Logtail machine group.
- Create a Logtail Config and apply it to the machine group.
- You have activated ECS and Log Service.
- You have create a project and a Logstore. For more information, see Preparations.
Note If your ECS instance uses a classic network or a VPC, the ECS instance and the Log Service project must belong to the same region.
- If the ECS instance is created under another Alibaba Cloud account, you cannot automatically obtain the ECS instance owner information. In this case, you must configure an AliUid for the ECS instance.
Step 1: Install Logtail.
- Run the installation command.
For example, if your Linux ECS instance belong to the China (Hangzhou) region and uses a classic network, you can run the following command to install Logtail:
wget http://logtail-release.oss-cn-hangzhou-internal.aliyuncs.com/linux64/logtail.sh; chmod 755 logtail.sh; sh logtail.sh install cn_hangzhou
- Check the Logtail run status by running the following command:
Logtail is successfully installed if
ilogtail is runningis returned.
Step 2: Configure a machine group.
- In the Log Service console, click the target project.
- On the Logstores page, click Logtail Machine Group in the left-side navigation pane.
- On the Machine Groups page, click Create Machine Group.
- In the displayed dialog box, enter your ECS intranet IP address and custom ID, and
then click Confirm.
- Only ECS instances that belong to the same region with the Log Service project is supported.
- Only ECS instances in the same region as the Log Service project are supported.
Step 3: Create a Logtail Config.
- On the Logstores page, find the target Logstore and click the Data Import Wizard icon.
- On the Select Data Source tab page, click Text File in the Custom Data.
- Configure the data source. For more information, see Collect text logs. This topic uses the Simple Mode as an example.
Enter the ECS log path in the Log Path text box, and then click Next.
- Select the machine group you created in Step 2 and click Apply to Machine Group.
You can then use Logtail to collect ECS logs. The following steps are for configuring indexes of collected logs or deliver logs.
Log on to the ECS console or run the
echo "test message" >> /var/log/message command. The new logs are generated in your local directory
/var/log/message. Logtail then collects the new logs and send them to Log Service.
On the Logstores page, find the target Logstore and click Search or Preview to view the logs collected by Logtail.